Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ on:
permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
lint-and-security-audit:
name: Lint, Syntax & Security Audit
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
persist-credentials: false

- name: Run Security, Secret & Syntax Audit
run: python3 scripts/security_audit.py
Expand All @@ -30,9 +37,12 @@ jobs:
python-lint-and-tests:
name: Python Lint & Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
persist-credentials: false

- name: Setup Python 3.12
uses: actions/setup-python@v7
Expand All @@ -53,11 +63,13 @@ jobs:
helm-lint-and-template:
name: Helm Lint, Schema & Template
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false

- name: Setup Python 3.12
uses: actions/setup-python@v7
Expand Down Expand Up @@ -103,13 +115,16 @@ jobs:
docker-and-kind:
name: Docker Build & Kind Helm Install
runs-on: ubuntu-latest
timeout-minutes: 25
needs:
- lint-and-security-audit
- python-lint-and-tests
- helm-lint-and-template
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
persist-credentials: false

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v4
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CodeQL

on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "17 6 * * 1"
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [python, actions]

steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
persist-credentials: false

- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
queries: security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v4

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{ matrix.language }}"
9 changes: 7 additions & 2 deletions .github/workflows/docs-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ on:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
Expand All @@ -29,12 +27,19 @@ jobs:
build-and-deploy:
name: Build & Deploy GitHub Pages
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
persist-credentials: false

- name: Setup Python 3.12
uses: actions/setup-python@v7
Expand Down
23 changes: 16 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ on:
workflow_dispatch:

permissions:
contents: write
packages: write
contents: read

jobs:
release:
name: Build Containers, Helm OCI & GitHub Release
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
packages: write
steps:
- name: Checkout Tag
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false

- name: Run Security & Syntax Audit
run: python3 scripts/security_audit.py
Expand All @@ -31,7 +35,7 @@ jobs:
else
VER=$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')
fi
echo "version=${VER}" >> "$GITHUB_OUTPUT"
printf 'version=%s\n' "${VER}" >> "$GITHUB_OUTPUT"
echo "Releasing nxtflow v${VER}"

- name: Setup QEMU & Docker Buildx
Expand Down Expand Up @@ -73,22 +77,27 @@ jobs:
version: "v4.3.1"

- name: Package & Push Helm Chart to GHCR OCI
env:
VER: ${{ steps.vars.outputs.version }}
GHCR_USER: ${{ github.actor }}
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VER="${{ steps.vars.outputs.version }}"
helm repo add grafana-community https://grafana-community.github.io/helm-charts
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm dependency build charts/nxtflow
mkdir -p dist
helm package charts/nxtflow --version "${VER}" --app-version "${VER}" -d dist/
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u "${{ github.actor }}" --password-stdin
printf '%s\n' "${GHCR_TOKEN}" | helm registry login ghcr.io -u "${GHCR_USER}" --password-stdin
helm push "dist/nxtflow-${VER}.tgz" oci://ghcr.io/nertwork/charts

- name: Build Python sdist & wheel
- name: Setup Python 3.12
uses: actions/setup-python@v7
with:
python-version: "3.12"
- run: |

- name: Build Python sdist & wheel
run: |
python -m pip install --upgrade pip build
python -m build --outdir dist/
cd dist
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ All notable changes to `nxtflow` are documented in this file.
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.4] - 2026-12-02

### Added
- **Version Display Across CLI, MCP, and Web UI**:
- Added `-V` / `--version` flag to the `nxtflow` CLI (`nxtflow 0.2.4`).
- Included `"version"` in `nxtflow-mcp` `/healthz` and `nxtflow-ui` `/healthz` & `/api/status` JSON responses.
- Added a live header version badge (`v0.2.4`) next to the `nxtflow` brand title in `nxtflow-ui`, populated via `textContent` from `/healthz` and `/api/status`.
- **GitHub CodeQL Code Scanning**:
- Added `.github/workflows/codeql.yml` (`python`, `actions`, `security-and-quality` queries) and hardened existing GitHub Actions workflows with minimal scoped permissions and `env:`-bound variables.

### Security
- **URL Scheme & TLS Hardening**:
- Added `validate_http_url()` in `nxtflow.config` and enforced `http://`/`https://` scheme validation prior to all `urllib.request.urlopen()` calls across `loki`, `victorialogs`, `clickhouse`, and `nxtflow-enricher` (`NetBoxSync` and `FlowShipper`).
- Replaced private `ssl._create_unverified_context()` calls with `ssl.create_default_context()` configuration and resolved Ruff `E,F,W,B,S,UP,SIM` code-quality and security checks across `src/nxtflow/`.

## [0.2.3] - 2026-12-02

### Changed
Expand Down
4 changes: 2 additions & 2 deletions charts/nxtflow/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: nxtflow
description: AI-ready multi-site NetFlow v5/v9, IPFIX, and sFlow collector, enricher, multi-backend storage (Loki, VictoriaLogs, ClickHouse), Grafana dashboard, and MCP server
type: application
version: 0.2.3
appVersion: "0.2.3"
version: 0.2.4
appVersion: "0.2.4"
home: https://github.com/nertwork/nxtflow
sources:
- https://github.com/nertwork/nxtflow
Expand Down
12 changes: 6 additions & 6 deletions charts/nxtflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Multi-protocol **NetFlow v5/v9, IPFIX, and sFlow v5** Kubernetes observability p

```bash
helm install nxtflow oci://ghcr.io/nertwork/charts/nxtflow \
--version 0.2.3 \
--version 0.2.4 \
--namespace nxtflow --create-namespace \
-f https://raw.githubusercontent.com/nertwork/nxtflow/main/examples/values-standalone.yaml
```
Expand All @@ -45,7 +45,7 @@ helm install nxtflow oci://ghcr.io/nertwork/charts/nxtflow \

```bash
helm install nxtflow oci://ghcr.io/nertwork/charts/nxtflow \
--version 0.2.3 \
--version 0.2.4 \
--namespace nxtflow --create-namespace \
-f https://raw.githubusercontent.com/nertwork/nxtflow/main/examples/values-loki.yaml
```
Expand All @@ -54,7 +54,7 @@ helm install nxtflow oci://ghcr.io/nertwork/charts/nxtflow \

```bash
helm install nxtflow oci://ghcr.io/nertwork/charts/nxtflow \
--version 0.2.3 \
--version 0.2.4 \
--namespace nxtflow --create-namespace \
-f https://raw.githubusercontent.com/nertwork/nxtflow/main/examples/values-clickhouse.yaml
```
Expand All @@ -63,7 +63,7 @@ helm install nxtflow oci://ghcr.io/nertwork/charts/nxtflow \

```bash
helm install nxtflow oci://ghcr.io/nertwork/charts/nxtflow \
--version 0.2.3 \
--version 0.2.4 \
--namespace monitoring \
-f https://raw.githubusercontent.com/nertwork/nxtflow/main/examples/values-integrated.yaml \
--set externalLoki.url="https://loki.example.com"
Expand All @@ -73,7 +73,7 @@ helm install nxtflow oci://ghcr.io/nertwork/charts/nxtflow \

```bash
helm install nxtflow-edge oci://ghcr.io/nertwork/charts/nxtflow \
--version 0.2.3 \
--version 0.2.4 \
--namespace nxtflow --create-namespace \
-f https://raw.githubusercontent.com/nertwork/nxtflow/main/examples/values-collector-only.yaml \
--set collector.site="edge-west" \
Expand Down Expand Up @@ -119,6 +119,6 @@ See [`values.yaml`](values.yaml) and [`values.schema.json`](values.schema.json)
## Upgrade & Uninstall

```bash
helm upgrade nxtflow oci://ghcr.io/nertwork/charts/nxtflow --version 0.2.3 -n nxtflow -f values.yaml
helm upgrade nxtflow oci://ghcr.io/nertwork/charts/nxtflow --version 0.2.4 -n nxtflow -f values.yaml
helm uninstall nxtflow -n nxtflow
```
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "nxtflow"
version = "0.2.3"
version = "0.2.4"
description = "AI-ready multi-site NetFlow v5/v9, IPFIX, and sFlow collector, enricher, Loki pipeline, CLI, and MCP server"
requires-python = ">=3.11"
license = {text = "MIT"}
Expand Down
2 changes: 1 addition & 1 deletion src/nxtflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""nxtflow — AI-ready multi-site NetFlow/IPFIX/sFlow telemetry toolkit."""

__version__ = "0.2.3"
__version__ = "0.2.4"
5 changes: 4 additions & 1 deletion src/nxtflow/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ def build_ssl_context(
"""Create SSLContext from bool/CA-path setting, raising error_cls on invalid paths."""
try:
if tls_verify is False:
return ssl._create_unverified_context()
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
return ctx
if isinstance(tls_verify, str):
return ssl.create_default_context(cafile=tls_verify)
return ssl.create_default_context()
Expand Down
9 changes: 8 additions & 1 deletion src/nxtflow/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import yaml

from nxtflow import __version__
from nxtflow.backends import BackendError, create_backend_client, safe_int
from nxtflow.config import load_config, validate_dir, validate_range

Expand Down Expand Up @@ -61,6 +62,7 @@ def build_parser() -> argparse.ArgumentParser:
description="Query multi-site NetFlow/IPFIX/sFlow telemetry.",
parents=[top_common],
)
parser.add_argument("-V", "--version", action="version", version=f"nxtflow {__version__}")
sub = parser.add_subparsers(dest="command", metavar="COMMAND")

sub.add_parser("status", aliases=["health"], parents=[sub_common], help="Collector stream & ingestion health")
Expand Down Expand Up @@ -199,7 +201,12 @@ def _render_top_ports(items: list[dict], n: int, range_str: str, site_val: str |

def _render_host(name: str, data: dict | None, range_str: str, as_json: bool) -> None:
if not data:
print(json.dumps({"host": name, "flows": 0}) if as_json else f"No traffic found for '{name}' in last {range_str}")
msg = (
json.dumps({"host": name, "flows": 0})
if as_json
else f"No traffic found for '{name}' in last {range_str}"
)
print(msg)
return
if as_json:
print(json.dumps(data, indent=2))
Expand Down
8 changes: 6 additions & 2 deletions src/nxtflow/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
sanitize_url_for_display,
validate_dir,
validate_header_value,
validate_http_url,
validate_range,
validate_sql_identifier,
)
Expand Down Expand Up @@ -114,7 +115,10 @@ def query_sql(
query_args[f"param_{key}"] = str(val)
qs = urllib.parse.urlencode(query_args)
base = self.config.clickhouse_url.rstrip("/")
url = f"{base}/?{qs}" if qs else f"{base}/"
try:
url = validate_http_url(f"{base}/?{qs}" if qs else f"{base}/", "clickhouse_url")
except ValueError as exc:
raise ClickHouseError(str(exc)) from exc
headers = self._build_headers()

try:
Expand All @@ -124,7 +128,7 @@ def query_sql(
headers=headers,
method="POST",
)
with urllib.request.urlopen(
with urllib.request.urlopen( # scheme validated via validate_http_url
req,
timeout=self.config.timeout_seconds,
context=self._ssl_ctx,
Expand Down
Loading