security-knowledge-os 0.1.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.
- security_knowledge_os-0.1.0/.env.example +22 -0
- security_knowledge_os-0.1.0/.gitignore +45 -0
- security_knowledge_os-0.1.0/LICENSE +202 -0
- security_knowledge_os-0.1.0/NOTICE +35 -0
- security_knowledge_os-0.1.0/PKG-INFO +348 -0
- security_knowledge_os-0.1.0/PUBLICATION_MANIFEST.md +956 -0
- security_knowledge_os-0.1.0/README.md +323 -0
- security_knowledge_os-0.1.0/REVIEW_CHECKLIST.md +255 -0
- security_knowledge_os-0.1.0/REVIEW_PACKAGE.md +184 -0
- security_knowledge_os-0.1.0/app/__init__.py +3 -0
- security_knowledge_os-0.1.0/app/cli.py +385 -0
- security_knowledge_os-0.1.0/app/config.py +89 -0
- security_knowledge_os-0.1.0/app/eval/__init__.py +2 -0
- security_knowledge_os-0.1.0/app/eval/metrics.py +123 -0
- security_knowledge_os-0.1.0/app/ingestion/__init__.py +1 -0
- security_knowledge_os-0.1.0/app/ingestion/chunker.py +36 -0
- security_knowledge_os-0.1.0/app/ingestion/loader.py +179 -0
- security_knowledge_os-0.1.0/app/ingestion/parser.py +256 -0
- security_knowledge_os-0.1.0/app/ingestion/snapshot.py +491 -0
- security_knowledge_os-0.1.0/app/ingestion/validator.py +397 -0
- security_knowledge_os-0.1.0/app/llm/__init__.py +1 -0
- security_knowledge_os-0.1.0/app/llm/anthropic_client.py +63 -0
- security_knowledge_os-0.1.0/app/llm/base.py +34 -0
- security_knowledge_os-0.1.0/app/llm/factory.py +29 -0
- security_knowledge_os-0.1.0/app/llm/mock.py +56 -0
- security_knowledge_os-0.1.0/app/main.py +1205 -0
- security_knowledge_os-0.1.0/app/models/__init__.py +99 -0
- security_knowledge_os-0.1.0/app/models/_credential_shapes.py +211 -0
- security_knowledge_os-0.1.0/app/models/answer.py +131 -0
- security_knowledge_os-0.1.0/app/models/assessment.py +373 -0
- security_knowledge_os-0.1.0/app/models/context.py +62 -0
- security_knowledge_os-0.1.0/app/models/knowledge.py +116 -0
- security_knowledge_os-0.1.0/app/models/llm_io.py +36 -0
- security_knowledge_os-0.1.0/app/models/policy_outcome.py +65 -0
- security_knowledge_os-0.1.0/app/models/report.py +73 -0
- security_knowledge_os-0.1.0/app/models/retrieval.py +128 -0
- security_knowledge_os-0.1.0/app/models/reviewer_output.py +77 -0
- security_knowledge_os-0.1.0/app/models/risk.py +124 -0
- security_knowledge_os-0.1.0/app/models/rule_clause.py +41 -0
- security_knowledge_os-0.1.0/app/policy/__init__.py +1 -0
- security_knowledge_os-0.1.0/app/policy/classification.py +57 -0
- security_knowledge_os-0.1.0/app/policy/human_gate.py +64 -0
- security_knowledge_os-0.1.0/app/policy/knowledge_guard.py +60 -0
- security_knowledge_os-0.1.0/app/policy/safe_test.py +319 -0
- security_knowledge_os-0.1.0/app/retrieval/__init__.py +1 -0
- security_knowledge_os-0.1.0/app/retrieval/base.py +92 -0
- security_knowledge_os-0.1.0/app/retrieval/bm25.py +84 -0
- security_knowledge_os-0.1.0/app/retrieval/hybrid.py +27 -0
- security_knowledge_os-0.1.0/app/retrieval/index.py +858 -0
- security_knowledge_os-0.1.0/app/reviewer/__init__.py +1 -0
- security_knowledge_os-0.1.0/app/reviewer/answers.py +99 -0
- security_knowledge_os-0.1.0/app/reviewer/assess.py +277 -0
- security_knowledge_os-0.1.0/app/reviewer/attack_surface.py +35 -0
- security_knowledge_os-0.1.0/app/reviewer/clause_eval.py +99 -0
- security_knowledge_os-0.1.0/app/reviewer/evidence.py +64 -0
- security_knowledge_os-0.1.0/app/reviewer/facts.py +129 -0
- security_knowledge_os-0.1.0/app/reviewer/llm_review.py +504 -0
- security_knowledge_os-0.1.0/app/reviewer/normalize.py +151 -0
- security_knowledge_os-0.1.0/app/reviewer/questions.py +75 -0
- security_knowledge_os-0.1.0/app/reviewer/report.py +128 -0
- security_knowledge_os-0.1.0/app/reviewer/rollup.py +91 -0
- security_knowledge_os-0.1.0/app/reviewer/rule_engine.py +223 -0
- security_knowledge_os-0.1.0/app/reviewer/rule_loader.py +347 -0
- security_knowledge_os-0.1.0/app/safe_errors.py +88 -0
- security_knowledge_os-0.1.0/app/storage/__init__.py +1 -0
- security_knowledge_os-0.1.0/app/storage/db.py +866 -0
- security_knowledge_os-0.1.0/app/storage/integrity.py +526 -0
- security_knowledge_os-0.1.0/app/storage/repository.py +164 -0
- security_knowledge_os-0.1.0/constraints.txt +98 -0
- security_knowledge_os-0.1.0/docs/acceptance-criteria.md +58 -0
- security_knowledge_os-0.1.0/docs/architecture.md +71 -0
- security_knowledge_os-0.1.0/docs/attribution.md +50 -0
- security_knowledge_os-0.1.0/docs/history-rewrite-map.md +244 -0
- security_knowledge_os-0.1.0/docs/knowledge-corpus.md +41 -0
- security_knowledge_os-0.1.0/docs/knowledge-schema.md +103 -0
- security_knowledge_os-0.1.0/docs/rule-schema.md +85 -0
- security_knowledge_os-0.1.0/docs/safe-test-schema.md +71 -0
- security_knowledge_os-0.1.0/docs/safety-boundaries.md +133 -0
- security_knowledge_os-0.1.0/docs/threat-model.md +103 -0
- security_knowledge_os-0.1.0/knowledge/private/README.md +11 -0
- security_knowledge_os-0.1.0/knowledge/private/confidential/.gitkeep +0 -0
- security_knowledge_os-0.1.0/knowledge/private/internal/.gitkeep +0 -0
- security_knowledge_os-0.1.0/knowledge/public/agent-security/.gitkeep +0 -0
- security_knowledge_os-0.1.0/knowledge/public/agent-security/KU-0004-excessive-agency-least-privilege.md +67 -0
- security_knowledge_os-0.1.0/knowledge/public/agent-security/KU-0005-human-approval-gates.md +67 -0
- security_knowledge_os-0.1.0/knowledge/public/agent-security/KU-0006-outbound-channels-allowlist.md +65 -0
- security_knowledge_os-0.1.0/knowledge/public/credential-security/.gitkeep +0 -0
- security_knowledge_os-0.1.0/knowledge/public/credential-security/KU-0008-secrets-not-reachable-by-model.md +67 -0
- security_knowledge_os-0.1.0/knowledge/public/credential-security/KU-0009-credential-broker-pattern.md +64 -0
- security_knowledge_os-0.1.0/knowledge/public/governance/KU-0012-human-oversight.md +64 -0
- security_knowledge_os-0.1.0/knowledge/public/incidents/.gitkeep +0 -0
- security_knowledge_os-0.1.0/knowledge/public/incidents/KU-0014-llm-payload-identifier-leak.md +147 -0
- security_knowledge_os-0.1.0/knowledge/public/memory-security/.gitkeep +0 -0
- security_knowledge_os-0.1.0/knowledge/public/memory-security/KU-0007-persistent-memory-poisoning.md +65 -0
- security_knowledge_os-0.1.0/knowledge/public/methodology/.gitkeep +0 -0
- security_knowledge_os-0.1.0/knowledge/public/methodology/KU-0011-improper-output-handling.md +62 -0
- security_knowledge_os-0.1.0/knowledge/public/methodology/KU-0013-assume-compromise-ja.md +68 -0
- security_knowledge_os-0.1.0/knowledge/public/prompt-security/.gitkeep +0 -0
- security_knowledge_os-0.1.0/knowledge/public/prompt-security/KU-0001-direct-prompt-injection.md +65 -0
- security_knowledge_os-0.1.0/knowledge/public/prompt-security/KU-0010-system-prompt-leakage.md +63 -0
- security_knowledge_os-0.1.0/knowledge/public/rag-security/.gitkeep +0 -0
- security_knowledge_os-0.1.0/knowledge/public/rag-security/KU-0002-indirect-prompt-injection.md +72 -0
- security_knowledge_os-0.1.0/knowledge/public/rag-security/KU-0003-untrusted-content-isolation.md +61 -0
- security_knowledge_os-0.1.0/pyproject.toml +133 -0
- security_knowledge_os-0.1.0/rules/agent/.gitkeep +0 -0
- security_knowledge_os-0.1.0/rules/agent/OUT-001.yaml +16 -0
- security_knowledge_os-0.1.0/rules/agent/TOOL-000.yaml +16 -0
- security_knowledge_os-0.1.0/rules/agent/TOOL-001.yaml +19 -0
- security_knowledge_os-0.1.0/rules/credential/.gitkeep +0 -0
- security_knowledge_os-0.1.0/rules/credential/CRED-001.yaml +24 -0
- security_knowledge_os-0.1.0/rules/governance/.gitkeep +0 -0
- security_knowledge_os-0.1.0/rules/governance/GOV-001.yaml +15 -0
- security_knowledge_os-0.1.0/rules/memory/.gitkeep +0 -0
- security_knowledge_os-0.1.0/rules/memory/MEM-001.yaml +20 -0
- security_knowledge_os-0.1.0/rules/prompt/.gitkeep +0 -0
- security_knowledge_os-0.1.0/rules/rag/.gitkeep +0 -0
- security_knowledge_os-0.1.0/rules/rag/PI-003.yaml +25 -0
- security_knowledge_os-0.1.0/safe_tests/ST-CRED-001.yaml +25 -0
- security_knowledge_os-0.1.0/safe_tests/ST-IPI-001.yaml +28 -0
- security_knowledge_os-0.1.0/safe_tests/ST-MEM-001.yaml +27 -0
- security_knowledge_os-0.1.0/safe_tests/ST-TOOL-001.yaml +25 -0
- security_knowledge_os-0.1.0/sbom.json +1293 -0
- security_knowledge_os-0.1.0/scripts/_scheduled_cross_review.sh +87 -0
- security_knowledge_os-0.1.0/scripts/assess.py +130 -0
- security_knowledge_os-0.1.0/scripts/build_index.py +127 -0
- security_knowledge_os-0.1.0/scripts/evaluate.py +135 -0
- security_knowledge_os-0.1.0/scripts/generate_sbom.py +378 -0
- security_knowledge_os-0.1.0/scripts/ingest.py +58 -0
- security_knowledge_os-0.1.0/scripts/preflight.py +710 -0
- security_knowledge_os-0.1.0/scripts/run_cross_review.sh +359 -0
- security_knowledge_os-0.1.0/scripts/secret_scan.py +128 -0
- security_knowledge_os-0.1.0/scripts/validate_knowledge.py +58 -0
- security_knowledge_os-0.1.0/scripts/validate_rules.py +47 -0
- security_knowledge_os-0.1.0/scripts/validate_safe_tests.py +46 -0
- security_knowledge_os-0.1.0/tests/conftest.py +71 -0
- security_knowledge_os-0.1.0/tests/fixtures/assessments/safe/S-001-prompt-only.yaml +13 -0
- security_knowledge_os-0.1.0/tests/fixtures/assessments/safe/S-002-rag-trusted-no-actions.yaml +16 -0
- security_knowledge_os-0.1.0/tests/fixtures/assessments/safe/S-003-readonly-tool-with-approval.yaml +17 -0
- security_knowledge_os-0.1.0/tests/fixtures/assessments/safe/S-004-credential-proxy.yaml +19 -0
- security_knowledge_os-0.1.0/tests/fixtures/assessments/unknown/U-001-tool-permissions-missing.yaml +14 -0
- security_knowledge_os-0.1.0/tests/fixtures/assessments/unknown/U-002-memory-persistence-unspecified.yaml +14 -0
- security_knowledge_os-0.1.0/tests/fixtures/assessments/unknown/U-003-outbound-destination-unspecified.yaml +18 -0
- security_knowledge_os-0.1.0/tests/fixtures/assessments/unknown/U-004-credential-handling-unspecified.yaml +17 -0
- security_knowledge_os-0.1.0/tests/fixtures/assessments/unknown/U-005-tool-permission-unrecognized.yaml +15 -0
- security_knowledge_os-0.1.0/tests/fixtures/assessments/vulnerable/V-001-indirect-injection-auto-email.yaml +20 -0
- security_knowledge_os-0.1.0/tests/fixtures/assessments/vulnerable/V-002-rag-delete-tool-no-approval.yaml +16 -0
- security_knowledge_os-0.1.0/tests/fixtures/assessments/vulnerable/V-003-persistent-memory-untrusted.yaml +16 -0
- security_knowledge_os-0.1.0/tests/fixtures/assessments/vulnerable/V-004-env-secret-readable.yaml +15 -0
- security_knowledge_os-0.1.0/tests/fixtures/assessments/vulnerable/V-005-unlisted-rag-source-untrusted-memory.yaml +15 -0
- security_knowledge_os-0.1.0/tests/fixtures/corpus/private/confidential/KU-1020-confidential-tool-matrix.md +55 -0
- security_knowledge_os-0.1.0/tests/fixtures/corpus/private/internal/KU-1010-internal-memory-heuristic.md +55 -0
- security_knowledge_os-0.1.0/tests/fixtures/corpus/public/credential-security/KU-1003-env-secret-exposure.md +59 -0
- security_knowledge_os-0.1.0/tests/fixtures/corpus/public/prompt-security/KU-1001-instruction-data-boundary.md +52 -0
- security_knowledge_os-0.1.0/tests/fixtures/corpus/public/rag-security/KU-1002-indirect-injection-external-document.md +63 -0
- security_knowledge_os-0.1.0/tests/fixtures/corpus/secret/KU-1099-secret-must-not-index.md +24 -0
- security_knowledge_os-0.1.0/tests/fixtures/corpus_alt/public/methodology/KU-2001-alt-corpus-marker.md +52 -0
- security_knowledge_os-0.1.0/tests/fixtures/knowledge/invalid/KU-0010-mislabeled.md +24 -0
- security_knowledge_os-0.1.0/tests/fixtures/knowledge/invalid/bad-classification.md +23 -0
- security_knowledge_os-0.1.0/tests/fixtures/knowledge/invalid/bad-id.md +23 -0
- security_knowledge_os-0.1.0/tests/fixtures/knowledge/invalid/missing-fields.md +8 -0
- security_knowledge_os-0.1.0/tests/fixtures/knowledge/invalid/no-front-matter.md +3 -0
- security_knowledge_os-0.1.0/tests/fixtures/knowledge/private/internal/KU-0002-internal-note.md +50 -0
- security_knowledge_os-0.1.0/tests/fixtures/knowledge/public/methodology/KU-0003-sparse.md +24 -0
- security_knowledge_os-0.1.0/tests/fixtures/knowledge/public/prompt-security/KU-0001-instruction-hierarchy.md +51 -0
- security_knowledge_os-0.1.0/tests/fixtures/knowledge/secret/KU-0009-secret.md +24 -0
- security_knowledge_os-0.1.0/tests/integration/.gitkeep +0 -0
- security_knowledge_os-0.1.0/tests/unit/test_answers.py +446 -0
- security_knowledge_os-0.1.0/tests/unit/test_anthropic_client.py +58 -0
- security_knowledge_os-0.1.0/tests/unit/test_api.py +1798 -0
- security_knowledge_os-0.1.0/tests/unit/test_assess.py +165 -0
- security_knowledge_os-0.1.0/tests/unit/test_assess_m4.py +92 -0
- security_knowledge_os-0.1.0/tests/unit/test_assess_m5.py +171 -0
- security_knowledge_os-0.1.0/tests/unit/test_assess_script.py +105 -0
- security_knowledge_os-0.1.0/tests/unit/test_assessment_input.py +145 -0
- security_knowledge_os-0.1.0/tests/unit/test_build_index_script.py +105 -0
- security_knowledge_os-0.1.0/tests/unit/test_classification_gate.py +219 -0
- security_knowledge_os-0.1.0/tests/unit/test_classification_leakage.py +115 -0
- security_knowledge_os-0.1.0/tests/unit/test_clause_eval.py +87 -0
- security_knowledge_os-0.1.0/tests/unit/test_cli.py +271 -0
- security_knowledge_os-0.1.0/tests/unit/test_config.py +166 -0
- security_knowledge_os-0.1.0/tests/unit/test_cross_review_script.py +162 -0
- security_knowledge_os-0.1.0/tests/unit/test_db.py +1084 -0
- security_knowledge_os-0.1.0/tests/unit/test_eval.py +126 -0
- security_knowledge_os-0.1.0/tests/unit/test_evaluate_script.py +54 -0
- security_knowledge_os-0.1.0/tests/unit/test_evidence.py +38 -0
- security_knowledge_os-0.1.0/tests/unit/test_fail_closed.py +871 -0
- security_knowledge_os-0.1.0/tests/unit/test_finding_boundary.py +49 -0
- security_knowledge_os-0.1.0/tests/unit/test_generate_sbom.py +357 -0
- security_knowledge_os-0.1.0/tests/unit/test_human_gate.py +38 -0
- security_knowledge_os-0.1.0/tests/unit/test_ingest_script.py +37 -0
- security_knowledge_os-0.1.0/tests/unit/test_ja_retrieval.py +56 -0
- security_knowledge_os-0.1.0/tests/unit/test_knowledge_corpus.py +56 -0
- security_knowledge_os-0.1.0/tests/unit/test_knowledge_guard.py +42 -0
- security_knowledge_os-0.1.0/tests/unit/test_knowledge_root_config.py +54 -0
- security_knowledge_os-0.1.0/tests/unit/test_knowledge_schema.py +121 -0
- security_knowledge_os-0.1.0/tests/unit/test_llm_adapter.py +51 -0
- security_knowledge_os-0.1.0/tests/unit/test_llm_boundary.py +125 -0
- security_knowledge_os-0.1.0/tests/unit/test_llm_output_schema.py +53 -0
- security_knowledge_os-0.1.0/tests/unit/test_llm_review.py +500 -0
- security_knowledge_os-0.1.0/tests/unit/test_loader.py +234 -0
- security_knowledge_os-0.1.0/tests/unit/test_no_code_execution.py +63 -0
- security_knowledge_os-0.1.0/tests/unit/test_no_secret_echo.py +445 -0
- security_knowledge_os-0.1.0/tests/unit/test_normalize.py +67 -0
- security_knowledge_os-0.1.0/tests/unit/test_parser.py +103 -0
- security_knowledge_os-0.1.0/tests/unit/test_policy_outcome.py +34 -0
- security_knowledge_os-0.1.0/tests/unit/test_preflight_manifest.py +407 -0
- security_knowledge_os-0.1.0/tests/unit/test_questions.py +52 -0
- security_knowledge_os-0.1.0/tests/unit/test_reindex.py +1464 -0
- security_knowledge_os-0.1.0/tests/unit/test_report.py +246 -0
- security_knowledge_os-0.1.0/tests/unit/test_repository.py +66 -0
- security_knowledge_os-0.1.0/tests/unit/test_retrieval.py +93 -0
- security_knowledge_os-0.1.0/tests/unit/test_rollup.py +116 -0
- security_knowledge_os-0.1.0/tests/unit/test_rule_engine.py +96 -0
- security_knowledge_os-0.1.0/tests/unit/test_rule_loader.py +381 -0
- security_knowledge_os-0.1.0/tests/unit/test_safe_test.py +385 -0
- security_knowledge_os-0.1.0/tests/unit/test_secret_scan.py +207 -0
- security_knowledge_os-0.1.0/tests/unit/test_snapshot.py +563 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Security Knowledge OS - example configuration.
|
|
2
|
+
# Copy to .env and adjust. NEVER commit a real .env or any API key.
|
|
3
|
+
|
|
4
|
+
# Assessment mode: private (public + internal) | public (public only)
|
|
5
|
+
SKOS_MODE=private
|
|
6
|
+
|
|
7
|
+
# Allow confidential-classified knowledge while in PRIVATE mode (explicit opt-in).
|
|
8
|
+
SKOS_ALLOW_CONFIDENTIAL=false
|
|
9
|
+
|
|
10
|
+
# LLM provider (decision A3): none (default, deterministic engine only)
|
|
11
|
+
# | mock (deterministic stub, for tests/demos)
|
|
12
|
+
# | anthropic | openai | local
|
|
13
|
+
SKOS_LLM_PROVIDER=none
|
|
14
|
+
|
|
15
|
+
# Only read when SKOS_LLM_PROVIDER=anthropic. Injected by the operator at runtime;
|
|
16
|
+
# never stored in this repository.
|
|
17
|
+
# ANTHROPIC_API_KEY=
|
|
18
|
+
# SKOS_LLM_MODEL=claude-sonnet-5
|
|
19
|
+
|
|
20
|
+
# Knowledge base location and retrieval depth.
|
|
21
|
+
SKOS_KNOWLEDGE_ROOT=knowledge
|
|
22
|
+
SKOS_TOP_K=5
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.venv/
|
|
6
|
+
venv/
|
|
7
|
+
.pytest_cache/
|
|
8
|
+
.mypy_cache/
|
|
9
|
+
.ruff_cache/
|
|
10
|
+
dist/
|
|
11
|
+
build/
|
|
12
|
+
|
|
13
|
+
# Secrets & local config (decision A3, 2026-09-10)
|
|
14
|
+
.env
|
|
15
|
+
*.local
|
|
16
|
+
*.key
|
|
17
|
+
*.pem
|
|
18
|
+
.claude/
|
|
19
|
+
|
|
20
|
+
# Pack Manager local state (Update Pack / Distribution Spec)
|
|
21
|
+
/packs/
|
|
22
|
+
/active/
|
|
23
|
+
/var/audit/
|
|
24
|
+
|
|
25
|
+
# --- Knowledge classification isolation (decision A1, 2026-09-10) ---
|
|
26
|
+
# Secret-classified knowledge must live OUTSIDE this repository, under a separate root.
|
|
27
|
+
/secret/
|
|
28
|
+
|
|
29
|
+
# Internal / confidential knowledge: keep the folder skeleton, ignore the content.
|
|
30
|
+
/knowledge/private/*
|
|
31
|
+
!/knowledge/private/README.md
|
|
32
|
+
!/knowledge/private/internal/
|
|
33
|
+
!/knowledge/private/confidential/
|
|
34
|
+
/knowledge/private/internal/*
|
|
35
|
+
!/knowledge/private/internal/.gitkeep
|
|
36
|
+
!/knowledge/private/internal/README.md
|
|
37
|
+
/knowledge/private/confidential/*
|
|
38
|
+
!/knowledge/private/confidential/.gitkeep
|
|
39
|
+
!/knowledge/private/confidential/README.md
|
|
40
|
+
|
|
41
|
+
# Local assessment artifacts / indexes
|
|
42
|
+
/var/
|
|
43
|
+
*.sqlite
|
|
44
|
+
*.sqlite3
|
|
45
|
+
*.db
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Security Knowledge OS
|
|
2
|
+
Copyright 2026 The Security Knowledge OS authors
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
--------------------------------------------------------------------------------
|
|
7
|
+
Third-party knowledge sources
|
|
8
|
+
--------------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
The Knowledge Units under knowledge/public/ are original prose that summarises
|
|
11
|
+
publicly documented security concepts. They do not reproduce third-party text
|
|
12
|
+
verbatim. Each unit records its source in a `provenance` block; docs/attribution.md
|
|
13
|
+
lists every source and its licence. In summary:
|
|
14
|
+
|
|
15
|
+
* OWASP Top 10 for LLM Applications 2025 (OWASP GenAI Security Project)
|
|
16
|
+
https://genai.owasp.org/ - CC-BY-SA-4.0
|
|
17
|
+
Referenced as the authoritative description of the risk categories.
|
|
18
|
+
The Knowledge Units are original wording, not derivative works of the
|
|
19
|
+
OWASP text.
|
|
20
|
+
|
|
21
|
+
* MITRE ATLAS - https://atlas.mitre.org/
|
|
22
|
+
MITRE ATLAS / ATT&CK Terms of Use (free use with attribution).
|
|
23
|
+
|
|
24
|
+
* NIST AI 600-1 (Generative AI Profile) and NIST AI Risk Management
|
|
25
|
+
Framework 1.0 - https://www.nist.gov/
|
|
26
|
+
U.S. Government works, not subject to copyright.
|
|
27
|
+
|
|
28
|
+
* simonwillison.net - referenced for context only; not reproduced.
|
|
29
|
+
|
|
30
|
+
--------------------------------------------------------------------------------
|
|
31
|
+
Runtime dependencies
|
|
32
|
+
--------------------------------------------------------------------------------
|
|
33
|
+
|
|
34
|
+
pydantic (MIT), PyYAML (MIT); optional: fastapi (MIT), uvicorn (BSD-3-Clause),
|
|
35
|
+
anthropic (MIT). See sbom.json.
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: security-knowledge-os
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Deterministic security assessment engine + knowledge retrieval + optional LLM assistance
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
License-File: NOTICE
|
|
8
|
+
Requires-Python: >=3.12
|
|
9
|
+
Requires-Dist: pydantic>=2.6
|
|
10
|
+
Requires-Dist: pyyaml>=6.0
|
|
11
|
+
Provides-Extra: api
|
|
12
|
+
Requires-Dist: fastapi>=0.132; extra == 'api'
|
|
13
|
+
Requires-Dist: uvicorn>=0.29; extra == 'api'
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: fastapi>=0.132; extra == 'dev'
|
|
16
|
+
Requires-Dist: httpx>=0.27; extra == 'dev'
|
|
17
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
18
|
+
Requires-Dist: pip-audit>=2.7; extra == 'dev'
|
|
19
|
+
Requires-Dist: pytest>=9.0.3; extra == 'dev'
|
|
20
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
21
|
+
Requires-Dist: types-pyyaml; extra == 'dev'
|
|
22
|
+
Provides-Extra: llm
|
|
23
|
+
Requires-Dist: anthropic>=0.40; extra == 'llm'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# Security Knowledge OS
|
|
27
|
+
|
|
28
|
+
> **Language note / 言語について**: This repository (code, docs, commit history) is
|
|
29
|
+
> **English-first by design** — it is written to be consumed by AI coding agents and
|
|
30
|
+
> cites international standards (OWASP, MITRE ATLAS, NIST) directly. The section
|
|
31
|
+
> below is a short Japanese summary for human reviewers; everything else in this repo
|
|
32
|
+
> stays English-only.
|
|
33
|
+
>
|
|
34
|
+
> 本リポジトリ(コード・docs・コミット履歴)は**英語がベース**です。AIコーディング
|
|
35
|
+
> エージェントに読ませる一次資料として書かれており、OWASP・MITRE ATLAS・NISTなどの
|
|
36
|
+
> 国際標準をそのまま引用しています。下の日本語要約は人間のレビュー用の窓口で、それ以外
|
|
37
|
+
> の部分(docs配下含む)は今後も英語のままにする方針です。
|
|
38
|
+
|
|
39
|
+
<details>
|
|
40
|
+
<summary>🇯🇵 日本語要約(クリックで開く)</summary>
|
|
41
|
+
|
|
42
|
+
**これは何か**: 既存のセキュリティ知識(メモ・GitHub・インシデント記録・実験ログ)を
|
|
43
|
+
バージョン管理された「Knowledge Unit」に変換し、決定論的なルールエンジンで
|
|
44
|
+
Prompt / RAG / Agent / Tool / Memory / Credential 面の一次AIセキュリティ査定を行うPoC。
|
|
45
|
+
LLMは**任意(デフォルトoff)の推論層**で、証拠集め・ルール照合・ギャップの指摘までを担当し、
|
|
46
|
+
最終判断は常に人間に返す設計。「AIが独断で"安全"と判定するツールではない」ことが前提。
|
|
47
|
+
|
|
48
|
+
**安全設計のポイント**:
|
|
49
|
+
- `PASS` はセキュリティの保証ではない。「評価範囲・入手した証拠・ルールセットの中で重大な
|
|
50
|
+
問題が見つからなかった」という意味にとどまる。
|
|
51
|
+
- `UNKNOWN`(証拠不十分で推測しない)は正式な判定結果。
|
|
52
|
+
- フィクスチャ(人工テストデータ)での指標は実世界の有効性を証明しない。
|
|
53
|
+
- デプロイ承認・リスク受容など高インパクトな判断は必ず人間の担当者。自動実行はせず
|
|
54
|
+
`HUMAN_APPROVAL_REQUIRED` を返す。
|
|
55
|
+
- 査定中、ナレッジリポジトリは読み取り専用。同じAIエージェントに自分のルール・知識を
|
|
56
|
+
書き換える権限は与えない(知識汚染対策)。
|
|
57
|
+
- 未検証の入力に含まれる「このルールを無視して」等の指示は常にデータとして扱い、
|
|
58
|
+
命令としては扱わない(プロンプトインジェクション対策)。
|
|
59
|
+
- 外部LLMに生の秘密情報(APIキー等)を送らない保証は、NGワードでのフィルタではなく
|
|
60
|
+
**構造的**(宛先名・ツール名は最初から匿名ラベルに置換してからLLMへ渡す)。
|
|
61
|
+
|
|
62
|
+
**現状**: M1〜M8のマイルストーンはすべて完了(`done`)。ライセンスはApache-2.0。
|
|
63
|
+
|
|
64
|
+
</details>
|
|
65
|
+
|
|
66
|
+
**Deterministic security-assessment engine + knowledge retrieval + optional LLM assistance.**
|
|
67
|
+
|
|
68
|
+
A PoC that converts existing security knowledge (notes, GitHub, incident records,
|
|
69
|
+
experiment logs) into versioned *Knowledge Units*, and uses a swappable general LLM
|
|
70
|
+
as an *optional* reasoning layer for first-pass AI-security assessment of
|
|
71
|
+
Prompt / RAG / Agent / Tool / Memory / Credential surfaces.
|
|
72
|
+
|
|
73
|
+
The source of truth for the design is the Google Drive document
|
|
74
|
+
*"Security Knowledge OS — Claude Code Implementation Specification v0.1"* (2026-09-10).
|
|
75
|
+
|
|
76
|
+
> This system is **not** an AI that decides "safe" on its own. It finds evidence,
|
|
77
|
+
> evaluates against rules, flags gaps, and supports a human decision.
|
|
78
|
+
|
|
79
|
+
## Security disclaimer & scope
|
|
80
|
+
|
|
81
|
+
- **This is a security assessment *support* tool, not a security guarantee.**
|
|
82
|
+
- **`PASS` is not a security guarantee.** It means "no major issue was detected
|
|
83
|
+
within the assessed scope, the available evidence, the active knowledge
|
|
84
|
+
revision, the rule set, and the model configuration". It does not prove the
|
|
85
|
+
target is secure.
|
|
86
|
+
- **`UNKNOWN` is a valid, first-class verdict** - it means evidence was
|
|
87
|
+
insufficient. The engine returns `UNKNOWN` rather than guessing.
|
|
88
|
+
- **Fixture performance is not real-world effectiveness.** The current metrics
|
|
89
|
+
(known-risk recall, false-positive rate, etc.) are measured on a small set of
|
|
90
|
+
*artificial* fixtures and show that the mechanism separates
|
|
91
|
+
vulnerable / safe / unknown as designed. They do **not** establish real-world
|
|
92
|
+
security effectiveness.
|
|
93
|
+
- **Human review is required.** High-impact decisions - deployment approval, risk
|
|
94
|
+
acceptance, and anything affecting money, people, contracts, production, or
|
|
95
|
+
external parties - stay with a named human owner. High-impact *actions* are
|
|
96
|
+
never auto-executed; the engine returns `HUMAN_APPROVAL_REQUIRED`.
|
|
97
|
+
- **The Knowledge Repository is read-only during assessment.** Retrieved content
|
|
98
|
+
can contain descriptions of prompt injection, tool abuse, and memory poisoning;
|
|
99
|
+
letting the same agent modify its own rules or knowledge would create a
|
|
100
|
+
knowledge-poisoning path. Do not grant an AI agent write access to the
|
|
101
|
+
production Knowledge Repository. Changes go through a separate review workflow.
|
|
102
|
+
|
|
103
|
+
### Trust boundary
|
|
104
|
+
|
|
105
|
+
| Trusted / controlled | Untrusted / potentially adversarial |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| Reviewed Knowledge Units | User prompts |
|
|
108
|
+
| Approved risk rules | External documents / web / PDF / images |
|
|
109
|
+
| Classification gate | RAG content before source & integrity verification |
|
|
110
|
+
| Deterministic rule engine | The assessed AI's own output |
|
|
111
|
+
| Human review / maintainer approval | LLM-generated observations & suggestions |
|
|
112
|
+
| | An update pack before verification |
|
|
113
|
+
|
|
114
|
+
"Ignore this rule" / "rewrite the knowledge" appearing in any untrusted input is
|
|
115
|
+
treated as data, never as a control instruction. Details in
|
|
116
|
+
`docs/safety-boundaries.md` and `docs/threat-model.md`.
|
|
117
|
+
|
|
118
|
+
## Core principles
|
|
119
|
+
|
|
120
|
+
- The LLM is **off by default**. `Input -> AssessmentContext -> Rule Engine -> Finding -> Report`
|
|
121
|
+
runs with no network, no API key, no LLM.
|
|
122
|
+
- Knowledge and the reasoning model are **separated**. The LLM is a replaceable layer.
|
|
123
|
+
- No unfounded guessing. `UNKNOWN` is a first-class verdict.
|
|
124
|
+
- The LLM layer can **never create or clear a `FAIL`** (decision A8).
|
|
125
|
+
- `public` / `internal` / `confidential` / `secret` are never mixed (decision A1).
|
|
126
|
+
- The final decision is always returned to a human.
|
|
127
|
+
|
|
128
|
+
## Milestone status
|
|
129
|
+
|
|
130
|
+
| Milestone | State | Deliverables |
|
|
131
|
+
| --- | --- | --- |
|
|
132
|
+
| **M1 — Skeleton + Schema + Validator** | done | directory tree, `app/models/*`, `app/ingestion/validator.py`, `scripts/validate_knowledge.py`, `docs/knowledge-schema.md` |
|
|
133
|
+
| **M2 — Knowledge Loader + FTS5 Retrieval** | done | `app/ingestion/{loader,chunker}.py`, `app/storage/{db,repository}.py`, `app/retrieval/{base,bm25,hybrid,index}.py`, `scripts/{ingest,build_index}.py` |
|
|
134
|
+
| **M3 — Deterministic Rule Engine** | done | `app/models/rule_clause.py`, `app/reviewer/{facts,clause_eval,rule_loader,rule_engine,normalize,attack_surface,evidence,rollup,assess}.py`, `rules/**` (7 rules), `scripts/validate_rules.py`, `docs/rule-schema.md` |
|
|
135
|
+
| **M4 — LLM Adapter + Reviewer** | done | `app/llm/{base,mock,anthropic_client,factory}.py`, `app/models/{reviewer_output,llm_io}.py`, `app/reviewer/{llm_review,questions}.py`, `assess()` full, `scripts/assess.py` |
|
|
136
|
+
| **M5 — Safe Test + Human Gate** | done | `app/models/policy_outcome.py`, `app/policy/{human_gate,knowledge_guard,safe_test}.py`, `app/storage/integrity.py`, `safe_tests/**` (4 templates), `scripts/validate_safe_tests.py` |
|
|
137
|
+
| **M6 — Orchestrator + CLI + API** | done | `app/models/report.py`, `app/reviewer/report.py`, `app/cli.py` (`skos`), `app/main.py` (FastAPI), `app/retrieval/index.py::reindex_atomic` |
|
|
138
|
+
| **M7 — Fixtures + Evaluation + starter KUs** | done | `knowledge/public/**` (14 KUs), `tests/fixtures/assessments/{safe,vulnerable,unknown}/`, `app/eval/metrics.py`, `scripts/evaluate.py`, JA retrieval (trigram) |
|
|
139
|
+
| **M8 — Docs + hardening** | done | Security disclaimer (AC-15–18), KU `provenance` schema, `docs/{attribution,threat-model,architecture}.md`, `sbom.json`, `scripts/{secret_scan,generate_sbom,preflight}.py` |
|
|
140
|
+
|
|
141
|
+
## Quickstart (M1)
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
python3.12 -m venv .venv
|
|
145
|
+
.venv/bin/pip install -e ".[api,llm,dev]" -c constraints.txt --build-constraint constraints.txt
|
|
146
|
+
|
|
147
|
+
# Validate the knowledge base (empty on a fresh checkout -> 0 issues)
|
|
148
|
+
.venv/bin/python scripts/validate_knowledge.py knowledge
|
|
149
|
+
|
|
150
|
+
# Load-check a knowledge root, then build the FTS5 index from it
|
|
151
|
+
.venv/bin/python scripts/ingest.py knowledge
|
|
152
|
+
.venv/bin/python scripts/build_index.py knowledge --db var/index.sqlite
|
|
153
|
+
|
|
154
|
+
# Validate the deterministic rule catalogue and the safe-test templates
|
|
155
|
+
.venv/bin/python scripts/validate_rules.py rules
|
|
156
|
+
.venv/bin/python scripts/validate_safe_tests.py safe_tests
|
|
157
|
+
|
|
158
|
+
# Run an assessment (provider=none by default: the deterministic engine does the work)
|
|
159
|
+
.venv/bin/skos assess tests/fixtures/assessments/V-001-indirect-injection-auto-email.yaml
|
|
160
|
+
.venv/bin/skos test # run all 14 fixtures as a smoke test
|
|
161
|
+
|
|
162
|
+
# Rebuild the FTS index (atomic + fail-closed; never touches knowledge content)
|
|
163
|
+
.venv/bin/skos reindex knowledge --db var/index.sqlite
|
|
164
|
+
|
|
165
|
+
# Local API (needs the [api] extra)
|
|
166
|
+
.venv/bin/uvicorn app.main:app
|
|
167
|
+
|
|
168
|
+
# Evaluate the engine + indexed knowledge against the labelled fixtures (§24 metrics)
|
|
169
|
+
.venv/bin/python scripts/evaluate.py --db var/index.sqlite
|
|
170
|
+
|
|
171
|
+
# Run the test-suite
|
|
172
|
+
.venv/bin/pytest -q
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The MVP ships **14 public Knowledge Units** (`knowledge/public/`; 13 from
|
|
176
|
+
published standards - OWASP LLM Top 10 2025, MITRE ATLAS, NIST AI RMF / AI 600-1;
|
|
177
|
+
one in Japanese - plus one, KU-0014, an original write-up of a vulnerability
|
|
178
|
+
class this project's own pre-publication review process actually found). Each
|
|
179
|
+
unit carries `provenance` (source title, URL, version, licence, derivation
|
|
180
|
+
status, last-verified date). See `docs/knowledge-corpus.md` and
|
|
181
|
+
`docs/attribution.md`.
|
|
182
|
+
|
|
183
|
+
**Internal fixture evaluation** (`scripts/evaluate.py`, 14 artificial fixtures ×
|
|
184
|
+
14 indexed KUs):
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
Classification Leakage = 0
|
|
188
|
+
Safe Test Safety Violation = 0
|
|
189
|
+
Human Gate Bypass = 0
|
|
190
|
+
current controlled-fixture metrics = 1.0
|
|
191
|
+
(known-risk recall, false-positive rate=0, UNKNOWN-appropriateness,
|
|
192
|
+
evidence coverage, citation/source match)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
These results **do not establish real-world security effectiveness**. They show
|
|
196
|
+
the mechanism behaves as designed on a controlled set.
|
|
197
|
+
|
|
198
|
+
### `skos` CLI
|
|
199
|
+
|
|
200
|
+
`validate-knowledge` · `validate-rules` · `validate-safe-tests` · `ingest` ·
|
|
201
|
+
`reindex` · `assess` · `report` · `test`. Exit codes: `0` ok, `1` findings
|
|
202
|
+
failure with `--strict`, `2` usage/input error, `3` `POLICY_BLOCKED`.
|
|
203
|
+
|
|
204
|
+
### API (`app/main.py`)
|
|
205
|
+
|
|
206
|
+
`POST /v1/assessments` · `GET /v1/assessments/{id}` ·
|
|
207
|
+
`POST /v1/assessments/{id}/answers` · `GET /v1/assessments/{id}/history` ·
|
|
208
|
+
`GET /v1/assessments/{id}/report` · `POST /v1/knowledge/validate` (read-only) ·
|
|
209
|
+
`POST /v1/knowledge/reindex` · `GET /health`.
|
|
210
|
+
|
|
211
|
+
`/answers` takes a **typed `AnswerPatch`** - an allow-list of fields a follow-up
|
|
212
|
+
question can fill (`memory_persistent`, `memory_scope`, `outbound_enabled`,
|
|
213
|
+
`credential_storage`, `tool_permissions`, `human_approval`, …). There is no
|
|
214
|
+
generic deep-merge and no field is *named* for a raw secret value.
|
|
215
|
+
|
|
216
|
+
The actual "never sends a raw secret to the external LLM" guarantee is
|
|
217
|
+
**structural, not a content filter**: fields that are identifiers/hostnames
|
|
218
|
+
*by contract* (`rag_sources`, `outbound_destinations`, `tool_permissions`/
|
|
219
|
+
`human_approval` keys, tool `name`s) are never forwarded to the LLM as their
|
|
220
|
+
real value at all - `app/reviewer/llm_review.py::build_payload()` replaces
|
|
221
|
+
each with a stable, locally-scoped anonymized label (`rag_source_1`,
|
|
222
|
+
`destination_1`, `tool_1`, `action_1`, …) before ever constructing the
|
|
223
|
+
request, consistently across `assessment_context` and `attack_surface` so
|
|
224
|
+
the LLM can still reason about structure (counts, permissions, which
|
|
225
|
+
labelled tool needs approval) and refer to a specific one across its own
|
|
226
|
+
observations. This closes the class outright: no value these fields could
|
|
227
|
+
ever hold - a known credential shape, an unknown future one, or a genuine
|
|
228
|
+
business secret that merely looks like an ordinary name - can reach the
|
|
229
|
+
provider through them, because the raw value is never serialized in the
|
|
230
|
+
first place (Codex#1, rounds 9-14, 2026-09-12 -- 2026-09-13, five rounds of
|
|
231
|
+
content-filter attempts each defeated by a new shape - see
|
|
232
|
+
`tests/unit/test_llm_review.py`). The ORIGINAL objects (used by the
|
|
233
|
+
deterministic rule engine, and returned to the calling human via
|
|
234
|
+
`AssessmentResult.attack_surface`) are untouched; only the LLM request-
|
|
235
|
+
building path is anonymized. `app/models/_credential_shapes.py`'s denylist
|
|
236
|
+
(known credential shapes) and allowlist (identifier-shaped values) remain
|
|
237
|
+
as defense in depth on these same fields, not as this boundary.
|
|
238
|
+
`system_prompt`/`developer_prompt` (actual prose, not identifiers) are
|
|
239
|
+
never anonymized and only get the denylist - an arbitrary opaque string
|
|
240
|
+
with no recognizable shape is indistinguishable from ordinary prose there.
|
|
241
|
+
Given this project's Vault-only credential policy, never place a real
|
|
242
|
+
secret in any assessment field regardless. **Rejected (HTTP 422):**
|
|
243
|
+
an unknown patch field, a permission value outside the closed enum, a type
|
|
244
|
+
mismatch. Tool names are *not* a fixed vocabulary - a diagnosed system can have
|
|
245
|
+
any tool name - so `tool_permissions[<new name>]` **adds** that tool to the
|
|
246
|
+
assessment (and a high-impact permission on it becomes a re-evaluation target);
|
|
247
|
+
`tool_permissions[<existing>]` replaces its permission. The patched input is
|
|
248
|
+
**re-assessed from scratch** - findings are never edited in place - and the new
|
|
249
|
+
result records `supersedes` and `revision`.
|
|
250
|
+
|
|
251
|
+
### Deviation from the spec
|
|
252
|
+
|
|
253
|
+
Spec Section 5 recommends **Typer** for the CLI; this build uses stdlib `argparse`
|
|
254
|
+
so the core install needs only `pydantic` + `pyyaml`. Spec Section 18's
|
|
255
|
+
`POST /v1/knowledge/reindex` is implemented as index-only re-derivation (it never
|
|
256
|
+
accepts or changes knowledge content).
|
|
257
|
+
|
|
258
|
+
**There is no endpoint that changes knowledge content.** `/v1/knowledge/reindex`
|
|
259
|
+
only re-derives the FTS index from the already-verified read-only knowledge root
|
|
260
|
+
(classification + integrity checked before an atomic swap; the old index is kept
|
|
261
|
+
on any failure).
|
|
262
|
+
|
|
263
|
+
HTTP status and policy outcome are separate layers: a policy-blocked assessment
|
|
264
|
+
is HTTP 422 with `status: "POLICY_BLOCKED"` and the `policy_decision` in the body,
|
|
265
|
+
never HTTP 200 with empty findings. `human_review_required` is a workflow flag
|
|
266
|
+
inside a `COMPLETED` (HTTP 200) body, not an error.
|
|
267
|
+
|
|
268
|
+
Rules are **data, never code** - see `docs/rule-schema.md`. The deterministic
|
|
269
|
+
assessment path (`app/reviewer/assess.py`) runs with no LLM: it normalizes the
|
|
270
|
+
input, extracts the attack surface, evaluates the rule catalogue over a
|
|
271
|
+
whitelisted fact set, and rolls the findings up. A rule is never `PASS` while any
|
|
272
|
+
check was `UNKNOWN` or any required evidence was missing.
|
|
273
|
+
|
|
274
|
+
The LLM is an **optional additive layer** (`SKOS_LLM_PROVIDER`, default `none`).
|
|
275
|
+
It receives the deterministic findings as a read-only view and its output schema
|
|
276
|
+
has no field for a status or an overall verdict, so it structurally cannot change
|
|
277
|
+
a deterministic result - it can only add `LLM-OBS-*` observations (capped at
|
|
278
|
+
`WARN`/`UNKNOWN`), questions, and notes. Malformed LLM output is repaired once,
|
|
279
|
+
then discarded (`LLM_PARSE_ERROR`).
|
|
280
|
+
|
|
281
|
+
**Policy outcomes are typed** (`PolicyOutcome`: `ALLOWED` /
|
|
282
|
+
`HUMAN_APPROVAL_REQUIRED` / `POLICY_BLOCKED` / `READ_ONLY_VIOLATION`), never bare
|
|
283
|
+
strings. The Human Gate fails closed - a recognised high-impact action, or any
|
|
284
|
+
unrecognised one, returns `HUMAN_APPROVAL_REQUIRED`. The Knowledge Repository is
|
|
285
|
+
read-only during assessment. Safe tests are **vetted templates only**
|
|
286
|
+
(`safe_tests/*.yaml`, passed through a deterministic validator that forbids real
|
|
287
|
+
secrets, external destinations, destructive operations and production targets);
|
|
288
|
+
an LLM's `safe_test_suggestions` land in `safe_test_proposals` as untrusted ideas
|
|
289
|
+
and are never promoted to an executable test automatically.
|
|
290
|
+
|
|
291
|
+
The knowledge root and index path are parameters (`SKOS_KNOWLEDGE_ROOT`,
|
|
292
|
+
`SKOS_DB_PATH`), so the same code serves `knowledge/` today and a Pack Manager's
|
|
293
|
+
`active/knowledge/` later. `top_k` counts Knowledge Units; secret-classified units
|
|
294
|
+
never enter the index.
|
|
295
|
+
|
|
296
|
+
`scripts/validate_knowledge.py` exits non-zero when any `ERROR`-level issue is found
|
|
297
|
+
(use `--strict` to also fail on warnings).
|
|
298
|
+
|
|
299
|
+
## Knowledge classification & layout (decision A1)
|
|
300
|
+
|
|
301
|
+
```
|
|
302
|
+
knowledge/
|
|
303
|
+
├─ public/ # git-tracked; retrievable in PUBLIC and PRIVATE mode
|
|
304
|
+
│ ├─ prompt-security/ rag-security/ agent-security/
|
|
305
|
+
│ ├─ memory-security/ credential-security/
|
|
306
|
+
│ └─ incidents/ methodology/
|
|
307
|
+
└─ private/ # git-ignored content (skeleton kept)
|
|
308
|
+
├─ internal/ # PRIVATE mode only
|
|
309
|
+
└─ confidential/ # PRIVATE mode + explicit --allow-confidential
|
|
310
|
+
|
|
311
|
+
secret/ # OUTSIDE this repository, separate root.
|
|
312
|
+
# Never indexed, never sent to an LLM.
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
`classification: secret` appearing anywhere inside the repo is a validator **ERROR**.
|
|
316
|
+
|
|
317
|
+
## LLM configuration (decision A3)
|
|
318
|
+
|
|
319
|
+
The default provider is `none`. To enable an external LLM, set both:
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
export SKOS_LLM_PROVIDER=anthropic
|
|
323
|
+
export ANTHROPIC_API_KEY=... # injected by the operator, never stored in the repo
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
See `.env.example`.
|
|
327
|
+
|
|
328
|
+
## Documentation
|
|
329
|
+
|
|
330
|
+
- `docs/architecture.md` — component overview and configurability seams
|
|
331
|
+
- `docs/threat-model.md` — assets, trust boundary, threats & controls, residual risks
|
|
332
|
+
- `docs/safety-boundaries.md` — decisions A1/A3/A6/A7/A8, Human Gate, §32 read-only, §33 trust boundary
|
|
333
|
+
- `docs/knowledge-schema.md` — Knowledge Unit schema (front matter + `provenance` + body)
|
|
334
|
+
- `docs/rule-schema.md` — data-only rule schema and operators
|
|
335
|
+
- `docs/safe-test-schema.md` — safe-test schema, validator rules, Human Gate, read-only guard
|
|
336
|
+
- `docs/knowledge-corpus.md` — the 14 shipped Knowledge Units and their sources
|
|
337
|
+
- `docs/attribution.md` — third-party sources, licences, derivation status
|
|
338
|
+
- `docs/acceptance-criteria.md` — AC-01..20 status and §24 evaluation metrics
|
|
339
|
+
|
|
340
|
+
## Licence
|
|
341
|
+
|
|
342
|
+
Apache License 2.0 — see `LICENSE` and `NOTICE`.
|
|
343
|
+
|
|
344
|
+
The engine code is licensed under Apache-2.0. The Knowledge Units under
|
|
345
|
+
`knowledge/public/` are original prose licensed under the same terms; they cite
|
|
346
|
+
public standards (OWASP, MITRE ATLAS, NIST) and do not reproduce third-party text
|
|
347
|
+
verbatim (see `docs/attribution.md`). A future commercial "Update Pack" would be
|
|
348
|
+
licensed separately (see the Update Pack / Distribution specification).
|