nextpolicyagent 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nextpolicyagent-1.0.0/.dockerignore +47 -0
- nextpolicyagent-1.0.0/.github/workflows/publish.yml +64 -0
- nextpolicyagent-1.0.0/.gitignore +44 -0
- nextpolicyagent-1.0.0/Dockerfile +81 -0
- nextpolicyagent-1.0.0/Documentation/CLI_Referenz.md +596 -0
- nextpolicyagent-1.0.0/Documentation/Docker-Anleitung.md +581 -0
- nextpolicyagent-1.0.0/Documentation/Konfigurationsreferenz.md +462 -0
- nextpolicyagent-1.0.0/Documentation/OPA_Analyse_und_Anforderungsprofil.md +998 -0
- nextpolicyagent-1.0.0/Documentation/OPA_vs_NPA_Gap_Analysis.md +426 -0
- nextpolicyagent-1.0.0/Documentation/Performance_Vergleich_OPA_vs_NPA.md +283 -0
- nextpolicyagent-1.0.0/Documentation/REST_API_Referenz.md +809 -0
- nextpolicyagent-1.0.0/Documentation/Rego_Sprachreferenz.md +688 -0
- nextpolicyagent-1.0.0/Documentation/SDK_Referenz.md +491 -0
- nextpolicyagent-1.0.0/Documentation/Schnellstart.md +638 -0
- nextpolicyagent-1.0.0/Documentation/Web_Dashboard.md +556 -0
- nextpolicyagent-1.0.0/LICENSE +674 -0
- nextpolicyagent-1.0.0/PKG-INFO +506 -0
- nextpolicyagent-1.0.0/README.md +451 -0
- nextpolicyagent-1.0.0/benchmark.py +633 -0
- nextpolicyagent-1.0.0/benchmark_results.json +120 -0
- nextpolicyagent-1.0.0/docker-compose.yml +47 -0
- nextpolicyagent-1.0.0/examples/README.md +231 -0
- nextpolicyagent-1.0.0/examples/data-filtering/data.json +11 -0
- nextpolicyagent-1.0.0/examples/data-filtering/input.json +4 -0
- nextpolicyagent-1.0.0/examples/data-filtering/policy.rego +81 -0
- nextpolicyagent-1.0.0/examples/http-api-authz/data.json +5 -0
- nextpolicyagent-1.0.0/examples/http-api-authz/input.json +6 -0
- nextpolicyagent-1.0.0/examples/http-api-authz/policy.rego +61 -0
- nextpolicyagent-1.0.0/examples/jwt-validation/data.json +9 -0
- nextpolicyagent-1.0.0/examples/jwt-validation/input.json +3 -0
- nextpolicyagent-1.0.0/examples/jwt-validation/policy.rego +41 -0
- nextpolicyagent-1.0.0/examples/kubernetes-admission/input-invalid.json +27 -0
- nextpolicyagent-1.0.0/examples/kubernetes-admission/input-valid.json +34 -0
- nextpolicyagent-1.0.0/examples/kubernetes-admission/policy.rego +47 -0
- nextpolicyagent-1.0.0/examples/network-firewall/input.json +6 -0
- nextpolicyagent-1.0.0/examples/network-firewall/policy.rego +58 -0
- nextpolicyagent-1.0.0/examples/plugins/README.md +125 -0
- nextpolicyagent-1.0.0/examples/plugins/__init__.py +1 -0
- nextpolicyagent-1.0.0/examples/plugins/audit_trail_plugin.py +205 -0
- nextpolicyagent-1.0.0/examples/plugins/builtin_config_plugin.py +235 -0
- nextpolicyagent-1.0.0/examples/plugins/metrics_plugin.py +249 -0
- nextpolicyagent-1.0.0/examples/plugins/rate_limit_plugin.py +205 -0
- nextpolicyagent-1.0.0/examples/plugins/webhook_notification_plugin.py +310 -0
- nextpolicyagent-1.0.0/examples/rbac/data.json +27 -0
- nextpolicyagent-1.0.0/examples/rbac/input.json +5 -0
- nextpolicyagent-1.0.0/examples/rbac/policy.rego +34 -0
- nextpolicyagent-1.0.0/npa/__init__.py +3 -0
- nextpolicyagent-1.0.0/npa/__main__.py +5 -0
- nextpolicyagent-1.0.0/npa/ast/__init__.py +1 -0
- nextpolicyagent-1.0.0/npa/ast/builtins.py +1692 -0
- nextpolicyagent-1.0.0/npa/ast/compiler.py +316 -0
- nextpolicyagent-1.0.0/npa/ast/lexer.py +249 -0
- nextpolicyagent-1.0.0/npa/ast/parser.py +848 -0
- nextpolicyagent-1.0.0/npa/ast/types.py +431 -0
- nextpolicyagent-1.0.0/npa/bundle/__init__.py +1 -0
- nextpolicyagent-1.0.0/npa/bundle/bundle.py +283 -0
- nextpolicyagent-1.0.0/npa/bundle/loader.py +106 -0
- nextpolicyagent-1.0.0/npa/bundle/sign.py +105 -0
- nextpolicyagent-1.0.0/npa/cli/__init__.py +1 -0
- nextpolicyagent-1.0.0/npa/cli/main.py +584 -0
- nextpolicyagent-1.0.0/npa/config/__init__.py +1 -0
- nextpolicyagent-1.0.0/npa/config/config.py +100 -0
- nextpolicyagent-1.0.0/npa/eval/__init__.py +1 -0
- nextpolicyagent-1.0.0/npa/eval/cache.py +154 -0
- nextpolicyagent-1.0.0/npa/eval/partial.py +275 -0
- nextpolicyagent-1.0.0/npa/eval/topdown.py +921 -0
- nextpolicyagent-1.0.0/npa/eval/unify.py +204 -0
- nextpolicyagent-1.0.0/npa/format/__init__.py +1 -0
- nextpolicyagent-1.0.0/npa/format/formatter.py +265 -0
- nextpolicyagent-1.0.0/npa/plugins/__init__.py +1 -0
- nextpolicyagent-1.0.0/npa/plugins/manager.py +570 -0
- nextpolicyagent-1.0.0/npa/sdk/__init__.py +1 -0
- nextpolicyagent-1.0.0/npa/sdk/sdk.py +147 -0
- nextpolicyagent-1.0.0/npa/server/__init__.py +1 -0
- nextpolicyagent-1.0.0/npa/server/app.py +286 -0
- nextpolicyagent-1.0.0/npa/server/auth.py +70 -0
- nextpolicyagent-1.0.0/npa/server/routes/__init__.py +1 -0
- nextpolicyagent-1.0.0/npa/server/routes/bundles.py +148 -0
- nextpolicyagent-1.0.0/npa/server/routes/config.py +43 -0
- nextpolicyagent-1.0.0/npa/server/routes/data.py +329 -0
- nextpolicyagent-1.0.0/npa/server/routes/health.py +81 -0
- nextpolicyagent-1.0.0/npa/server/routes/metrics.py +63 -0
- nextpolicyagent-1.0.0/npa/server/routes/policy.py +166 -0
- nextpolicyagent-1.0.0/npa/server/routes/query.py +236 -0
- nextpolicyagent-1.0.0/npa/server/routes/ui_api.py +425 -0
- nextpolicyagent-1.0.0/npa/server/static/css/npa.css +1020 -0
- nextpolicyagent-1.0.0/npa/server/static/index.html +122 -0
- nextpolicyagent-1.0.0/npa/server/static/js/app.js +246 -0
- nextpolicyagent-1.0.0/npa/server/static/js/pages/bundles.js +192 -0
- nextpolicyagent-1.0.0/npa/server/static/js/pages/config.js +175 -0
- nextpolicyagent-1.0.0/npa/server/static/js/pages/dashboard.js +224 -0
- nextpolicyagent-1.0.0/npa/server/static/js/pages/databrowser.js +218 -0
- nextpolicyagent-1.0.0/npa/server/static/js/pages/logs.js +180 -0
- nextpolicyagent-1.0.0/npa/server/static/js/pages/playground.js +287 -0
- nextpolicyagent-1.0.0/npa/server/static/js/pages/policies.js +295 -0
- nextpolicyagent-1.0.0/npa/storage/__init__.py +1 -0
- nextpolicyagent-1.0.0/npa/storage/base.py +97 -0
- nextpolicyagent-1.0.0/npa/storage/disk.py +175 -0
- nextpolicyagent-1.0.0/npa/storage/inmemory.py +175 -0
- nextpolicyagent-1.0.0/npa/util/__init__.py +1 -0
- nextpolicyagent-1.0.0/npa.ini +84 -0
- nextpolicyagent-1.0.0/pyproject.toml +108 -0
- nextpolicyagent-1.0.0/requirements.txt +57 -0
- nextpolicyagent-1.0.0/start-npa.ps1 +316 -0
- nextpolicyagent-1.0.0/start-npa.sh +273 -0
- nextpolicyagent-1.0.0/stop-npa.ps1 +186 -0
- nextpolicyagent-1.0.0/stop-npa.sh +179 -0
- nextpolicyagent-1.0.0/test_evaluator.py +436 -0
- nextpolicyagent-1.0.0/test_formatter.py +94 -0
- nextpolicyagent-1.0.0/test_new_features.py +91 -0
- nextpolicyagent-1.0.0/test_parser.py +111 -0
- nextpolicyagent-1.0.0/test_phase8_features.py +477 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Git
|
|
2
|
+
.git
|
|
3
|
+
.gitignore
|
|
4
|
+
|
|
5
|
+
# Python
|
|
6
|
+
__pycache__
|
|
7
|
+
*.pyc
|
|
8
|
+
*.pyo
|
|
9
|
+
*.egg-info
|
|
10
|
+
dist/
|
|
11
|
+
build/
|
|
12
|
+
.eggs/
|
|
13
|
+
*.egg
|
|
14
|
+
|
|
15
|
+
# Virtual environments
|
|
16
|
+
.venv
|
|
17
|
+
venv
|
|
18
|
+
env
|
|
19
|
+
|
|
20
|
+
# IDE
|
|
21
|
+
.vscode
|
|
22
|
+
.idea
|
|
23
|
+
*.swp
|
|
24
|
+
*.swo
|
|
25
|
+
|
|
26
|
+
# Tests & dev
|
|
27
|
+
.pytest_cache
|
|
28
|
+
.mypy_cache
|
|
29
|
+
.ruff_cache
|
|
30
|
+
.coverage
|
|
31
|
+
htmlcov/
|
|
32
|
+
test_*.py
|
|
33
|
+
_test_*.py
|
|
34
|
+
|
|
35
|
+
# OS
|
|
36
|
+
Thumbs.db
|
|
37
|
+
.DS_Store
|
|
38
|
+
|
|
39
|
+
# OPA reference (not needed in container)
|
|
40
|
+
../OPA
|
|
41
|
+
../certs
|
|
42
|
+
|
|
43
|
+
# Docs (optional, keep README)
|
|
44
|
+
Documentation/
|
|
45
|
+
*.md
|
|
46
|
+
!README.md
|
|
47
|
+
!examples/README.md
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
name: Build distribution
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
- name: Install build tools
|
|
20
|
+
run: pip install build
|
|
21
|
+
- name: Build package
|
|
22
|
+
run: python -m build
|
|
23
|
+
- name: Upload artifacts
|
|
24
|
+
uses: actions/upload-artifact@v4
|
|
25
|
+
with:
|
|
26
|
+
name: dist
|
|
27
|
+
path: dist/
|
|
28
|
+
|
|
29
|
+
test:
|
|
30
|
+
name: Test package
|
|
31
|
+
needs: build
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v4
|
|
35
|
+
- uses: actions/setup-python@v5
|
|
36
|
+
with:
|
|
37
|
+
python-version: "3.12"
|
|
38
|
+
- name: Download artifacts
|
|
39
|
+
uses: actions/download-artifact@v4
|
|
40
|
+
with:
|
|
41
|
+
name: dist
|
|
42
|
+
path: dist/
|
|
43
|
+
- name: Install package from wheel
|
|
44
|
+
run: pip install dist/*.whl
|
|
45
|
+
- name: Verify CLI entry point
|
|
46
|
+
run: npa --help
|
|
47
|
+
- name: Verify import
|
|
48
|
+
run: python -c "import npa; print(npa.__version__)"
|
|
49
|
+
|
|
50
|
+
publish-pypi:
|
|
51
|
+
name: Publish to PyPI
|
|
52
|
+
needs: test
|
|
53
|
+
runs-on: ubuntu-latest
|
|
54
|
+
environment: release
|
|
55
|
+
permissions:
|
|
56
|
+
id-token: write
|
|
57
|
+
steps:
|
|
58
|
+
- name: Download artifacts
|
|
59
|
+
uses: actions/download-artifact@v4
|
|
60
|
+
with:
|
|
61
|
+
name: dist
|
|
62
|
+
path: dist/
|
|
63
|
+
- name: Publish to PyPI
|
|
64
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.egg-info/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
*.egg
|
|
9
|
+
|
|
10
|
+
# Virtual environments
|
|
11
|
+
.venv/
|
|
12
|
+
venv/
|
|
13
|
+
env/
|
|
14
|
+
|
|
15
|
+
# IDE
|
|
16
|
+
.vscode/
|
|
17
|
+
.idea/
|
|
18
|
+
*.swp
|
|
19
|
+
*.swo
|
|
20
|
+
|
|
21
|
+
# OS
|
|
22
|
+
Thumbs.db
|
|
23
|
+
.DS_Store
|
|
24
|
+
|
|
25
|
+
# Logs
|
|
26
|
+
*.log
|
|
27
|
+
npa.log
|
|
28
|
+
|
|
29
|
+
# PID files
|
|
30
|
+
*.pid
|
|
31
|
+
npa.pid
|
|
32
|
+
|
|
33
|
+
# Backups
|
|
34
|
+
*.bak
|
|
35
|
+
|
|
36
|
+
# Certs (sensitive)
|
|
37
|
+
certs/
|
|
38
|
+
|
|
39
|
+
# pytest
|
|
40
|
+
.pytest_cache/
|
|
41
|
+
|
|
42
|
+
# Coverage
|
|
43
|
+
htmlcov/
|
|
44
|
+
.coverage
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# ──────────────────────────────────────────────────────────
|
|
2
|
+
# NPA – Next Policy Agent | Fedora-based Container
|
|
3
|
+
# ──────────────────────────────────────────────────────────
|
|
4
|
+
# Multi-stage build:
|
|
5
|
+
# 1) builder – install deps in venv
|
|
6
|
+
# 2) runtime – lean Fedora image with only what's needed
|
|
7
|
+
#
|
|
8
|
+
# Build:
|
|
9
|
+
# docker build -t npa .
|
|
10
|
+
#
|
|
11
|
+
# Run:
|
|
12
|
+
# docker run -p 8443:8443 npa
|
|
13
|
+
# docker run -p 8443:8443 -v ./policies:/policies -v ./data:/data npa
|
|
14
|
+
# docker compose up
|
|
15
|
+
# ──────────────────────────────────────────────────────────
|
|
16
|
+
|
|
17
|
+
# ── Stage 1: Builder ─────────────────────────────────────
|
|
18
|
+
FROM registry.fedoraproject.org/fedora:41 AS builder
|
|
19
|
+
|
|
20
|
+
RUN dnf install -y python3 python3-pip python3-devel gcc && \
|
|
21
|
+
dnf clean all
|
|
22
|
+
|
|
23
|
+
WORKDIR /build
|
|
24
|
+
|
|
25
|
+
# Install dependencies first (layer caching)
|
|
26
|
+
COPY pyproject.toml README.md ./
|
|
27
|
+
RUN python3 -m venv /opt/npa-venv && \
|
|
28
|
+
/opt/npa-venv/bin/pip install --no-cache-dir --upgrade pip && \
|
|
29
|
+
/opt/npa-venv/bin/pip install --no-cache-dir .
|
|
30
|
+
|
|
31
|
+
# Copy source and reinstall with actual code
|
|
32
|
+
COPY npa/ ./npa/
|
|
33
|
+
RUN /opt/npa-venv/bin/pip install --no-cache-dir .
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# ── Stage 2: Runtime ─────────────────────────────────────
|
|
37
|
+
FROM registry.fedoraproject.org/fedora:41
|
|
38
|
+
|
|
39
|
+
LABEL maintainer="NPA Team" \
|
|
40
|
+
description="Next Policy Agent – OPA-compatible policy engine" \
|
|
41
|
+
org.opencontainers.image.source="https://github.com/BLS-ISP/NextPolicyAgent"
|
|
42
|
+
|
|
43
|
+
# Minimal runtime deps only
|
|
44
|
+
RUN dnf install -y python3 && \
|
|
45
|
+
dnf clean all && \
|
|
46
|
+
rm -rf /var/cache/dnf
|
|
47
|
+
|
|
48
|
+
# Copy venv from builder
|
|
49
|
+
COPY --from=builder /opt/npa-venv /opt/npa-venv
|
|
50
|
+
|
|
51
|
+
# Add venv to PATH
|
|
52
|
+
ENV PATH="/opt/npa-venv/bin:$PATH" \
|
|
53
|
+
PYTHONUNBUFFERED=1 \
|
|
54
|
+
PYTHONDONTWRITEBYTECODE=1
|
|
55
|
+
|
|
56
|
+
# Create non-root user
|
|
57
|
+
RUN useradd --system --create-home --shell /usr/sbin/nologin npa
|
|
58
|
+
|
|
59
|
+
# Create directories for policies, data, bundles and certs
|
|
60
|
+
RUN mkdir -p /policies /data /bundles /certs && \
|
|
61
|
+
chown -R npa:npa /policies /data /bundles /certs
|
|
62
|
+
|
|
63
|
+
# Copy examples
|
|
64
|
+
COPY --chown=npa:npa examples/ /examples/
|
|
65
|
+
|
|
66
|
+
WORKDIR /home/npa
|
|
67
|
+
|
|
68
|
+
# Switch to non-root user
|
|
69
|
+
USER npa
|
|
70
|
+
|
|
71
|
+
# NPA default port (HTTPS)
|
|
72
|
+
EXPOSE 8443
|
|
73
|
+
|
|
74
|
+
# Health check via the health endpoint
|
|
75
|
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
76
|
+
CMD python3 -c "import urllib.request, ssl; ctx=ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE; urllib.request.urlopen('https://localhost:8443/health', context=ctx)" || exit 1
|
|
77
|
+
|
|
78
|
+
# Default: start NPA server with auto-generated self-signed TLS cert
|
|
79
|
+
# Override with environment variables or mount config/certs
|
|
80
|
+
ENTRYPOINT ["python3", "-m", "npa", "run"]
|
|
81
|
+
CMD ["--addr", "0.0.0.0:8443", "--log-level", "info"]
|