@ai-primitives-hub/core 0.2.1 → 0.2.2-next.0
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.
- package/dist/domain/bundle/version.d.ts +13 -0
- package/dist/domain/bundle/version.d.ts.map +1 -1
- package/dist/domain/bundle/version.js +27 -0
- package/dist/domain/bundle/version.js.map +1 -1
- package/dist/domain/collection/apm-release-plan.d.ts +39 -0
- package/dist/domain/collection/apm-release-plan.d.ts.map +1 -0
- package/dist/domain/collection/apm-release-plan.js +185 -0
- package/dist/domain/collection/apm-release-plan.js.map +1 -0
- package/dist/domain/collection/contribution.d.ts +126 -0
- package/dist/domain/collection/contribution.d.ts.map +1 -0
- package/dist/domain/collection/contribution.js +462 -0
- package/dist/domain/collection/contribution.js.map +1 -0
- package/dist/domain/collection/diagnostics.d.ts +166 -0
- package/dist/domain/collection/diagnostics.d.ts.map +1 -0
- package/dist/domain/collection/diagnostics.js +3 -0
- package/dist/domain/collection/diagnostics.js.map +1 -0
- package/dist/domain/collection/manifest-validator.d.ts +3 -2
- package/dist/domain/collection/manifest-validator.d.ts.map +1 -1
- package/dist/domain/collection/manifest-validator.js +99 -17
- package/dist/domain/collection/manifest-validator.js.map +1 -1
- package/dist/domain/collection/release-manifest-plan.d.ts +9 -0
- package/dist/domain/collection/release-manifest-plan.d.ts.map +1 -1
- package/dist/domain/collection/release-manifest-plan.js +45 -14
- package/dist/domain/collection/release-manifest-plan.js.map +1 -1
- package/dist/domain/collection/validate.d.ts +5 -0
- package/dist/domain/collection/validate.d.ts.map +1 -1
- package/dist/domain/collection/validate.js +7 -2
- package/dist/domain/collection/validate.js.map +1 -1
- package/dist/domain/diagnostics/primitives/catalogue.d.ts +40 -0
- package/dist/domain/diagnostics/primitives/catalogue.d.ts.map +1 -0
- package/dist/domain/diagnostics/primitives/catalogue.js +78 -0
- package/dist/domain/diagnostics/primitives/catalogue.js.map +1 -0
- package/dist/domain/diagnostics/primitives/classifier.d.ts +81 -0
- package/dist/domain/diagnostics/primitives/classifier.d.ts.map +1 -0
- package/dist/domain/diagnostics/primitives/classifier.js +138 -0
- package/dist/domain/diagnostics/primitives/classifier.js.map +1 -0
- package/dist/domain/diagnostics/primitives/evaluators.d.ts +138 -0
- package/dist/domain/diagnostics/primitives/evaluators.d.ts.map +1 -0
- package/dist/domain/diagnostics/primitives/evaluators.js +485 -0
- package/dist/domain/diagnostics/primitives/evaluators.js.map +1 -0
- package/dist/domain/diagnostics/primitives/fixture.d.ts +97 -0
- package/dist/domain/diagnostics/primitives/fixture.d.ts.map +1 -0
- package/dist/domain/diagnostics/primitives/fixture.js +265 -0
- package/dist/domain/diagnostics/primitives/fixture.js.map +1 -0
- package/dist/domain/diagnostics/primitives/index.d.ts +18 -0
- package/dist/domain/diagnostics/primitives/index.d.ts.map +1 -0
- package/dist/domain/diagnostics/primitives/index.js +34 -0
- package/dist/domain/diagnostics/primitives/index.js.map +1 -0
- package/dist/domain/diagnostics/primitives/known-gaps.d.ts +50 -0
- package/dist/domain/diagnostics/primitives/known-gaps.d.ts.map +1 -0
- package/dist/domain/diagnostics/primitives/known-gaps.js +148 -0
- package/dist/domain/diagnostics/primitives/known-gaps.js.map +1 -0
- package/dist/domain/diagnostics/primitives/manifest-view.d.ts +28 -0
- package/dist/domain/diagnostics/primitives/manifest-view.d.ts.map +1 -0
- package/dist/domain/diagnostics/primitives/manifest-view.js +50 -0
- package/dist/domain/diagnostics/primitives/manifest-view.js.map +1 -0
- package/dist/domain/diagnostics/primitives/placements.d.ts +51 -0
- package/dist/domain/diagnostics/primitives/placements.d.ts.map +1 -0
- package/dist/domain/diagnostics/primitives/placements.js +76 -0
- package/dist/domain/diagnostics/primitives/placements.js.map +1 -0
- package/dist/domain/diagnostics/primitives/planner.d.ts +60 -0
- package/dist/domain/diagnostics/primitives/planner.d.ts.map +1 -0
- package/dist/domain/diagnostics/primitives/planner.js +60 -0
- package/dist/domain/diagnostics/primitives/planner.js.map +1 -0
- package/dist/domain/diagnostics/primitives/plugin-projection.d.ts +38 -0
- package/dist/domain/diagnostics/primitives/plugin-projection.d.ts.map +1 -0
- package/dist/domain/diagnostics/primitives/plugin-projection.js +173 -0
- package/dist/domain/diagnostics/primitives/plugin-projection.js.map +1 -0
- package/dist/domain/diagnostics/primitives/report.d.ts +122 -0
- package/dist/domain/diagnostics/primitives/report.d.ts.map +1 -0
- package/dist/domain/diagnostics/primitives/report.js +85 -0
- package/dist/domain/diagnostics/primitives/report.js.map +1 -0
- package/dist/domain/diagnostics/primitives/sandbox.d.ts +59 -0
- package/dist/domain/diagnostics/primitives/sandbox.d.ts.map +1 -0
- package/dist/domain/diagnostics/primitives/sandbox.js +193 -0
- package/dist/domain/diagnostics/primitives/sandbox.js.map +1 -0
- package/dist/domain/diagnostics/primitives/support-matrix.d.ts +36 -0
- package/dist/domain/diagnostics/primitives/support-matrix.d.ts.map +1 -0
- package/dist/domain/diagnostics/primitives/support-matrix.js +69 -0
- package/dist/domain/diagnostics/primitives/support-matrix.js.map +1 -0
- package/dist/domain/diagnostics/primitives/types.d.ts +117 -0
- package/dist/domain/diagnostics/primitives/types.d.ts.map +1 -0
- package/dist/domain/diagnostics/primitives/types.js +62 -0
- package/dist/domain/diagnostics/primitives/types.js.map +1 -0
- package/dist/domain/governance/catalogue.d.ts +11 -0
- package/dist/domain/governance/catalogue.d.ts.map +1 -0
- package/dist/domain/governance/catalogue.js +45 -0
- package/dist/domain/governance/catalogue.js.map +1 -0
- package/dist/domain/governance/effective-rules.d.ts +19 -0
- package/dist/domain/governance/effective-rules.d.ts.map +1 -0
- package/dist/domain/governance/effective-rules.js +49 -0
- package/dist/domain/governance/effective-rules.js.map +1 -0
- package/dist/domain/governance/evaluate.d.ts +16 -0
- package/dist/domain/governance/evaluate.d.ts.map +1 -0
- package/dist/domain/governance/evaluate.js +34 -0
- package/dist/domain/governance/evaluate.js.map +1 -0
- package/dist/domain/governance/hub-scope.d.ts +74 -0
- package/dist/domain/governance/hub-scope.d.ts.map +1 -0
- package/dist/domain/governance/hub-scope.js +202 -0
- package/dist/domain/governance/hub-scope.js.map +1 -0
- package/dist/domain/governance/hub-scoped-inventory.d.ts +22 -0
- package/dist/domain/governance/hub-scoped-inventory.d.ts.map +1 -0
- package/dist/domain/governance/hub-scoped-inventory.js +59 -0
- package/dist/domain/governance/hub-scoped-inventory.js.map +1 -0
- package/dist/domain/governance/index.d.ts +15 -0
- package/dist/domain/governance/index.d.ts.map +1 -0
- package/dist/domain/governance/index.js +31 -0
- package/dist/domain/governance/index.js.map +1 -0
- package/dist/domain/governance/rule-registry.d.ts +20 -0
- package/dist/domain/governance/rule-registry.d.ts.map +1 -0
- package/dist/domain/governance/rule-registry.js +40 -0
- package/dist/domain/governance/rule-registry.js.map +1 -0
- package/dist/domain/governance/rules/collection.d.ts +32 -0
- package/dist/domain/governance/rules/collection.d.ts.map +1 -0
- package/dist/domain/governance/rules/collection.js +153 -0
- package/dist/domain/governance/rules/collection.js.map +1 -0
- package/dist/domain/governance/rules/config.d.ts +15 -0
- package/dist/domain/governance/rules/config.d.ts.map +1 -0
- package/dist/domain/governance/rules/config.js +38 -0
- package/dist/domain/governance/rules/config.js.map +1 -0
- package/dist/domain/governance/rules/hub.d.ts +7 -0
- package/dist/domain/governance/rules/hub.d.ts.map +1 -0
- package/dist/domain/governance/rules/hub.js +10 -0
- package/dist/domain/governance/rules/hub.js.map +1 -0
- package/dist/domain/governance/types.d.ts +70 -0
- package/dist/domain/governance/types.d.ts.map +1 -0
- package/dist/domain/governance/types.js +7 -0
- package/dist/domain/governance/types.js.map +1 -0
- package/dist/domain/hub/diagnostics.d.ts +92 -0
- package/dist/domain/hub/diagnostics.d.ts.map +1 -0
- package/dist/domain/hub/diagnostics.js +11 -0
- package/dist/domain/hub/diagnostics.js.map +1 -0
- package/dist/domain/hub/profile-requirements.d.ts +16 -0
- package/dist/domain/hub/profile-requirements.d.ts.map +1 -0
- package/dist/domain/hub/profile-requirements.js +16 -0
- package/dist/domain/hub/profile-requirements.js.map +1 -0
- package/dist/domain/hub/replicate.d.ts +23 -0
- package/dist/domain/hub/replicate.d.ts.map +1 -1
- package/dist/domain/hub/replicate.js +13 -0
- package/dist/domain/hub/replicate.js.map +1 -1
- package/dist/domain/hub/types.d.ts +2 -0
- package/dist/domain/hub/types.d.ts.map +1 -1
- package/dist/domain/hub/validate.d.ts +150 -2
- package/dist/domain/hub/validate.d.ts.map +1 -1
- package/dist/domain/hub/validate.js +421 -37
- package/dist/domain/hub/validate.js.map +1 -1
- package/dist/domain/index.d.ts +17 -0
- package/dist/domain/index.d.ts.map +1 -1
- package/dist/domain/index.js +17 -0
- package/dist/domain/index.js.map +1 -1
- package/dist/domain/install/category.d.ts +31 -0
- package/dist/domain/install/category.d.ts.map +1 -0
- package/dist/domain/install/category.js +33 -0
- package/dist/domain/install/category.js.map +1 -0
- package/dist/domain/install/file-mode.d.ts +49 -0
- package/dist/domain/install/file-mode.d.ts.map +1 -0
- package/dist/domain/install/file-mode.js +54 -0
- package/dist/domain/install/file-mode.js.map +1 -0
- package/dist/domain/install/git-exclude.d.ts +22 -0
- package/dist/domain/install/git-exclude.d.ts.map +1 -0
- package/dist/domain/install/git-exclude.js +56 -0
- package/dist/domain/install/git-exclude.js.map +1 -0
- package/dist/domain/install/installable.d.ts +2 -0
- package/dist/domain/install/installable.d.ts.map +1 -1
- package/dist/domain/install/kind-route.d.ts +80 -0
- package/dist/domain/install/kind-route.d.ts.map +1 -0
- package/dist/domain/install/kind-route.js +135 -0
- package/dist/domain/install/kind-route.js.map +1 -0
- package/dist/domain/install/record-errors.d.ts +53 -0
- package/dist/domain/install/record-errors.d.ts.map +1 -0
- package/dist/domain/install/record-errors.js +104 -0
- package/dist/domain/install/record-errors.js.map +1 -0
- package/dist/domain/install/record-object.d.ts +21 -0
- package/dist/domain/install/record-object.d.ts.map +1 -0
- package/dist/domain/install/record-object.js +38 -0
- package/dist/domain/install/record-object.js.map +1 -0
- package/dist/domain/install/record-parse.d.ts +23 -0
- package/dist/domain/install/record-parse.d.ts.map +1 -0
- package/dist/domain/install/record-parse.js +73 -0
- package/dist/domain/install/record-parse.js.map +1 -0
- package/dist/domain/install/record-path.d.ts +26 -0
- package/dist/domain/install/record-path.d.ts.map +1 -0
- package/dist/domain/install/record-path.js +130 -0
- package/dist/domain/install/record-path.js.map +1 -0
- package/dist/domain/install/record-types.d.ts +183 -0
- package/dist/domain/install/record-types.d.ts.map +1 -0
- package/dist/domain/install/record-types.js +92 -0
- package/dist/domain/install/record-types.js.map +1 -0
- package/dist/domain/install/types.d.ts +2 -0
- package/dist/domain/install/types.d.ts.map +1 -1
- package/dist/domain/mcp/index.d.ts +1 -0
- package/dist/domain/mcp/index.d.ts.map +1 -1
- package/dist/domain/mcp/index.js +1 -0
- package/dist/domain/mcp/index.js.map +1 -1
- package/dist/domain/mcp/server-key.d.ts +35 -0
- package/dist/domain/mcp/server-key.d.ts.map +1 -0
- package/dist/domain/mcp/server-key.js +44 -0
- package/dist/domain/mcp/server-key.js.map +1 -0
- package/dist/domain/plugin/agent-plugin-spec.d.ts +8 -0
- package/dist/domain/plugin/agent-plugin-spec.d.ts.map +1 -1
- package/dist/domain/plugin/agent-plugin-spec.js +22 -8
- package/dist/domain/plugin/agent-plugin-spec.js.map +1 -1
- package/dist/domain/registry-error.d.ts +1 -1
- package/dist/domain/registry-error.d.ts.map +1 -1
- package/dist/domain/registry-error.js +2 -1
- package/dist/domain/registry-error.js.map +1 -1
- package/dist/domain/security/fingerprint.d.ts +18 -0
- package/dist/domain/security/fingerprint.d.ts.map +1 -0
- package/dist/domain/security/fingerprint.js +34 -0
- package/dist/domain/security/fingerprint.js.map +1 -0
- package/dist/domain/security/high-impact-rules.d.ts +30 -0
- package/dist/domain/security/high-impact-rules.d.ts.map +1 -0
- package/dist/domain/security/high-impact-rules.js +160 -0
- package/dist/domain/security/high-impact-rules.js.map +1 -0
- package/dist/domain/security/index.d.ts +10 -0
- package/dist/domain/security/index.d.ts.map +1 -0
- package/dist/domain/security/index.js +26 -0
- package/dist/domain/security/index.js.map +1 -0
- package/dist/domain/security/markdown-context.d.ts +17 -0
- package/dist/domain/security/markdown-context.d.ts.map +1 -0
- package/dist/domain/security/markdown-context.js +74 -0
- package/dist/domain/security/markdown-context.js.map +1 -0
- package/dist/domain/security/policy.d.ts +17 -0
- package/dist/domain/security/policy.d.ts.map +1 -0
- package/dist/domain/security/policy.js +31 -0
- package/dist/domain/security/policy.js.map +1 -0
- package/dist/domain/security/rating/findings-document.d.ts +22 -0
- package/dist/domain/security/rating/findings-document.d.ts.map +1 -0
- package/dist/domain/security/rating/findings-document.js +57 -0
- package/dist/domain/security/rating/findings-document.js.map +1 -0
- package/dist/domain/security/rating/index.d.ts +5 -0
- package/dist/domain/security/rating/index.d.ts.map +1 -0
- package/dist/domain/security/rating/index.js +21 -0
- package/dist/domain/security/rating/index.js.map +1 -0
- package/dist/domain/security/rating/scoring.d.ts +83 -0
- package/dist/domain/security/rating/scoring.d.ts.map +1 -0
- package/dist/domain/security/rating/scoring.js +115 -0
- package/dist/domain/security/rating/scoring.js.map +1 -0
- package/dist/domain/security/rating/security-rating-report.d.ts +111 -0
- package/dist/domain/security/rating/security-rating-report.d.ts.map +1 -0
- package/dist/domain/security/rating/security-rating-report.js +152 -0
- package/dist/domain/security/rating/security-rating-report.js.map +1 -0
- package/dist/domain/security/rating/types.d.ts +22 -0
- package/dist/domain/security/rating/types.d.ts.map +1 -0
- package/dist/domain/security/rating/types.js +11 -0
- package/dist/domain/security/rating/types.js.map +1 -0
- package/dist/domain/security/remediations.d.ts +17 -0
- package/dist/domain/security/remediations.d.ts.map +1 -0
- package/dist/domain/security/remediations.js +61 -0
- package/dist/domain/security/remediations.js.map +1 -0
- package/dist/domain/security/rule-engine.d.ts +8 -0
- package/dist/domain/security/rule-engine.d.ts.map +1 -0
- package/dist/domain/security/rule-engine.js +875 -0
- package/dist/domain/security/rule-engine.js.map +1 -0
- package/dist/domain/security/suppression.d.ts +19 -0
- package/dist/domain/security/suppression.d.ts.map +1 -0
- package/dist/domain/security/suppression.js +78 -0
- package/dist/domain/security/suppression.js.map +1 -0
- package/dist/domain/security/types.d.ts +91 -0
- package/dist/domain/security/types.d.ts.map +1 -0
- package/dist/domain/security/types.js +10 -0
- package/dist/domain/security/types.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/ports/app-storage.d.ts +11 -15
- package/dist/ports/app-storage.d.ts.map +1 -1
- package/dist/ports/app-storage.js +8 -8
- package/dist/ports/argv-process-runner.d.ts +6 -0
- package/dist/ports/argv-process-runner.d.ts.map +1 -0
- package/dist/ports/argv-process-runner.js +3 -0
- package/dist/ports/argv-process-runner.js.map +1 -0
- package/dist/ports/bundle-extractor.d.ts +16 -3
- package/dist/ports/bundle-extractor.d.ts.map +1 -1
- package/dist/ports/collection-contribution.d.ts +36 -0
- package/dist/ports/collection-contribution.d.ts.map +1 -0
- package/dist/ports/collection-contribution.js +3 -0
- package/dist/ports/collection-contribution.js.map +1 -0
- package/dist/ports/filesystem.d.ts +12 -0
- package/dist/ports/filesystem.d.ts.map +1 -1
- package/dist/ports/hub-collection-index.d.ts +27 -0
- package/dist/ports/hub-collection-index.d.ts.map +1 -0
- package/dist/ports/hub-collection-index.js +3 -0
- package/dist/ports/hub-collection-index.js.map +1 -0
- package/dist/ports/hub-contribution.d.ts +158 -0
- package/dist/ports/hub-contribution.d.ts.map +1 -0
- package/dist/ports/hub-contribution.js +3 -0
- package/dist/ports/hub-contribution.js.map +1 -0
- package/dist/ports/index.d.ts +12 -0
- package/dist/ports/index.d.ts.map +1 -1
- package/dist/ports/index.js +12 -0
- package/dist/ports/index.js.map +1 -1
- package/dist/ports/primitive-diagnostics-driver.d.ts +96 -0
- package/dist/ports/primitive-diagnostics-driver.d.ts.map +1 -0
- package/dist/ports/primitive-diagnostics-driver.js +3 -0
- package/dist/ports/primitive-diagnostics-driver.js.map +1 -0
- package/dist/ports/record-fs.d.ts +46 -0
- package/dist/ports/record-fs.d.ts.map +1 -0
- package/dist/ports/record-fs.js +9 -0
- package/dist/ports/record-fs.js.map +1 -0
- package/dist/ports/registry-operations.d.ts +3 -2
- package/dist/ports/registry-operations.d.ts.map +1 -1
- package/dist/ports/release-lookup.d.ts +24 -0
- package/dist/ports/release-lookup.d.ts.map +1 -0
- package/dist/ports/release-lookup.js +7 -0
- package/dist/ports/release-lookup.js.map +1 -0
- package/dist/ports/release-source.d.ts +17 -3
- package/dist/ports/release-source.d.ts.map +1 -1
- package/dist/ports/repository-exclusion.d.ts +30 -0
- package/dist/ports/repository-exclusion.d.ts.map +1 -0
- package/dist/ports/repository-exclusion.js +3 -0
- package/dist/ports/repository-exclusion.js.map +1 -0
- package/dist/ports/schema-validator.d.ts +25 -0
- package/dist/ports/schema-validator.d.ts.map +1 -0
- package/dist/ports/schema-validator.js +7 -0
- package/dist/ports/schema-validator.js.map +1 -0
- package/dist/ports/security-report-store.d.ts +9 -0
- package/dist/ports/security-report-store.d.ts.map +1 -0
- package/dist/ports/security-report-store.js +4 -0
- package/dist/ports/security-report-store.js.map +1 -0
- package/dist/ports/security-scan-engine.d.ts +32 -0
- package/dist/ports/security-scan-engine.d.ts.map +1 -0
- package/dist/ports/security-scan-engine.js +6 -0
- package/dist/ports/security-scan-engine.js.map +1 -0
- package/dist/ports/security-scan-input.d.ts +63 -0
- package/dist/ports/security-scan-input.d.ts.map +1 -0
- package/dist/ports/security-scan-input.js +3 -0
- package/dist/ports/security-scan-input.js.map +1 -0
- package/dist/ports/source-adapter.d.ts +11 -0
- package/dist/ports/source-adapter.d.ts.map +1 -1
- package/dist/public/schemas/collection.schema.json +0 -1
- package/dist/public/schemas/hub-governance.schema.json +21 -0
- package/dist/public/schemas/install-record.schema.json +343 -0
- package/dist/public/schemas/security-rating-report.schema.json +113 -0
- package/package.json +2 -2
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INFORMATIONAL_CONTROL_RULES = exports.HIGH_IMPACT_DOCUMENT_RULES = exports.HIGH_IMPACT_LINE_RULES = exports.hasUnpinnedPipInstall = void 0;
|
|
4
|
+
const rule = (id, title, severity, category, pattern, options = {}) => ({
|
|
5
|
+
id,
|
|
6
|
+
title,
|
|
7
|
+
severity,
|
|
8
|
+
category,
|
|
9
|
+
pattern,
|
|
10
|
+
confidence: 'HIGH',
|
|
11
|
+
...options
|
|
12
|
+
});
|
|
13
|
+
// pip options that take a separate value; the value is not a package.
|
|
14
|
+
const PIP_VALUE_OPTIONS = new Set([
|
|
15
|
+
'-i', '--index-url', '--extra-index-url', '-c', '--constraint', '-t', '--target', '--prefix', '-f', '--find-links',
|
|
16
|
+
'--proxy', '--root', '--src', '--cache-dir', '--log', '--retries', '--timeout', '--trusted-host', '--cert',
|
|
17
|
+
'--client-cert', '--python', '--platform', '--python-version', '--implementation', '--abi', '--report',
|
|
18
|
+
'--upgrade-strategy', '--no-binary', '--only-binary', '--progress-bar', '--exists-action', '-C', '--config-settings'
|
|
19
|
+
]);
|
|
20
|
+
/**
|
|
21
|
+
* True when a `pip install` on the line has a package that is not pinned with `==`, or names no package.
|
|
22
|
+
* A requirements file (`-r`) is treated as pinned.
|
|
23
|
+
* @param line - Line that matched a pip install
|
|
24
|
+
*/
|
|
25
|
+
const hasUnpinnedPipInstall = (line) => {
|
|
26
|
+
for (const command of line.matchAll(/\bpip\d*\s+install\b([^|;&]*)/gi)) {
|
|
27
|
+
const tokens = command[1].trim().split(/\s+/).filter((token) => token !== '');
|
|
28
|
+
let pinned = 0;
|
|
29
|
+
let unpinned = 0;
|
|
30
|
+
let requirements = false;
|
|
31
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
32
|
+
const token = tokens[index];
|
|
33
|
+
if (token === '-r' || token === '--requirement' || token.startsWith('--requirement=') || /^-r\S/.test(token)) {
|
|
34
|
+
requirements = true;
|
|
35
|
+
}
|
|
36
|
+
else if (PIP_VALUE_OPTIONS.has(token)) {
|
|
37
|
+
index += 1;
|
|
38
|
+
}
|
|
39
|
+
else if (!token.startsWith('-')) {
|
|
40
|
+
if (token.includes('==')) {
|
|
41
|
+
pinned += 1;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
unpinned += 1;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (!requirements && (unpinned > 0 || pinned === 0)) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
};
|
|
54
|
+
exports.hasUnpinnedPipInstall = hasUnpinnedPipInstall;
|
|
55
|
+
const hook = (id, title, severity, pattern, options = {}) => rule(id, title, severity, 'hook_injection', pattern, {
|
|
56
|
+
skipExample: true,
|
|
57
|
+
...options
|
|
58
|
+
});
|
|
59
|
+
exports.HIGH_IMPACT_LINE_RULES = [
|
|
60
|
+
hook('HKS-003', 'Credential Store or Cloud Metadata Service Access', 'CRITICAL', /\bsecurity\s+find-(?:generic|internet)-password\b|\bsecret-tool\s+lookup\b|\bgit\s+credential\s+fill\b|(?:\/etc\/shadow|\/etc\/passwd|\.ssh\/id_(?:rsa|ed25519|ecdsa)(?:\.pub)?)\b|(?:curl|wget)\s+http:\/\/169\.254\.169\.254\//i),
|
|
61
|
+
hook('HKS-004', 'Clipboard Exfiltration via Clipboard Utility', 'HIGH', /\bpbcopy\b|\bxclip\s+-sel\s+clip\b|\bxsel\s+--clipboard\b|\bwl-copy\b/i, { skipCode: true }),
|
|
62
|
+
hook('HKS-005', 'Log Tampering / Anti-Forensics Pattern', 'HIGH', /journalctl\s+--vacuum|rm\s+(?:-[rfF]+\s+)?\/var\/log|(?:cat|echo)\s+\/dev\/null\s+>\s+\/var\/log|\bhistory\s+-[cwrd]\b|\bunset\s+HISTFILE\b|\bexport\s+HISTFILESIZE\s*=\s*0\b/i),
|
|
63
|
+
hook('HKS-006', 'Container Escape — Privileged Flags or Host Namespace Access', 'CRITICAL', /\s--privileged\b|--pid\s*=\s*host\b|\s-v\s+\/:\/|--cap-add\s+(?:SYS_PTRACE|SYS_ADMIN|ALL)\b/i, { skipCode: true }),
|
|
64
|
+
hook('HKS-007', 'Global Package Install in Hook/Script — Supply Chain Risk', 'HIGH', /\bnpm\s+(?:install|i)\s+-g\b|\bgem\s+install\b|\bcargo\s+install\b(?!\s+--locked)/i, { skipCode: true, confidence: 'MEDIUM' }),
|
|
65
|
+
hook('HKS-007', 'Global Package Install in Hook/Script — Supply Chain Risk', 'HIGH', /\bpip\d*\s+install\b/i, { skipCode: true, confidence: 'MEDIUM', lineTest: exports.hasUnpinnedPipInstall }),
|
|
66
|
+
hook('HKS-008', 'Silent Error Suppression in Security-Sensitive Hook Context', 'HIGH', /2\s*>\s*\/dev\/null\s*[|;]|\|\|\s*true\b|\|\|\s*:\s*(?:$|\n)|2>&1.*>\/dev\/null/i, {
|
|
67
|
+
confidence: 'MEDIUM',
|
|
68
|
+
contextPattern: /\b(?:security|auth|credential|password|token|key|secret|permission|verify|check|validate|scan|monitor|log|audit|deny|block|guard)\b/i,
|
|
69
|
+
contextRadius: 3,
|
|
70
|
+
requireContext: true
|
|
71
|
+
}),
|
|
72
|
+
hook('HKS-009', 'System-Level Persistence via Cron or Init Framework', 'CRITICAL', /crontab\s+-[el]|>>\s*\/etc\/cron|cron\.(?:d|daily|weekly|hourly)\/|systemctl\s+enable|launchctl\s+load|launchd\b.*plist\b/i),
|
|
73
|
+
hook('HKS-010', 'Shell Profile Hijacking — Appending to Shell Startup Files', 'CRITICAL', />>\s*~\/\.(?:bashrc|zshrc|bash_profile|profile|zprofile|bash_login)|tee\s+-a\s+~\/\.(?:bashrc|zshrc|bash_profile|profile)|echo\b[^|]*>>\s*\/etc\/(?:environment|profile|bash\.bashrc)/i, { skipCode: true }),
|
|
74
|
+
hook('HKS-011', 'SSH Key Manipulation', 'CRITICAL', />>\s*~\/\.ssh\/authorized_keys|ssh-keygen\s+-[tNb]|ssh-copy-id\b/i),
|
|
75
|
+
hook('HKS-012', 'Network Listener Opened by Agent', 'CRITICAL', /\bnc\s+(?:-[klnvze]\s*)+\d{2,5}|\bnc\s+-l(?:nvp?)?\s+\d{2,5}|\bsocat\s+TCP-LISTEN:|python\d*\s+-m\s+(?:http\.server|SimpleHTTPServer)|php\s+-S\b/i),
|
|
76
|
+
hook('HKS-013', 'Disk Wipe / Destructive Filesystem Command', 'CRITICAL', /\bdd\s+if=\/dev\/(?:zero|urandom)\b|\bmkfs(?:\.\w+)?\b|\bwipefs\b|\bshred\s+-(?:[uvz]|n\d)/i),
|
|
77
|
+
hook('HKS-014', 'Privilege Escalation — Privileged Shell', 'CRITICAL', /\bpkexec\b|\bdoas\s+\S|\brunas\s+\/user:|\bsudo\s+(?:su|bash|sh|zsh|ksh|fish|-i\b|-s\b)|\bsu\s+-[lm]?\s*root\b/i),
|
|
78
|
+
hook('HKS-015', 'User Account Manipulation', 'CRITICAL', /\b(?:useradd|adduser|usermod|userdel)\b|\bpasswd\s+\w|\bgpasswd\b/i),
|
|
79
|
+
hook('HKS-016', 'Dangerous Git Configuration Change', 'HIGH', /git\s+config\b.*\b(?:core\.hooksPath|commit\.gpgsign|safe\.directory)\b|git\s+config\s+--system\b/i),
|
|
80
|
+
hook('HKS-017', 'Environment Variable Hijacking', 'HIGH', /\bexport\s+(?:LD_PRELOAD|LD_LIBRARY_PATH|DYLD_INSERT_LIBRARIES|PYTHONPATH)\s*=|\bexport\s+NODE_OPTIONS\s*=\s*["']*--require/i),
|
|
81
|
+
hook('HKS-018', 'Firewall Rule Modification', 'CRITICAL', /\biptables\s+-[ADI]\b|\bufw\s+(?:allow|delete|disable)\b|\bfirewall-cmd\s+--(?:add|remove)-(?:port|service)|\bnft\s+(?:add|insert|delete)\s+rule\b/i),
|
|
82
|
+
hook('HKS-019', 'DNS Exfiltration via Variable Expansion', 'CRITICAL', /\bdig\b[^"\n]*\$[{(]?\w+[})]?\.[a-z]{2,}|\bnslookup\b[^"\n]*\$[{(]?\w+[})]?\.|\bhost\b\s+\$[{(]?\w+/i),
|
|
83
|
+
hook('HKS-020', 'Background Process Daemonization', 'HIGH', /\bnohup\s+\S.*&\s*$|\bdisown\b|\bscreen\s+-dm\b|\btmux\s+new-session\s+-d\b/i, { skipCode: true, confidence: 'MEDIUM', relatedAst: 'AST06:2026' }),
|
|
84
|
+
hook('HKS-021', 'File Shredding / Unrecoverable Deletion', 'HIGH', /\bshred\b\s+(?:-[uvzn]\s+)*[^\s]|\brm\s+(?:-\w*f\w*\s+|--force\s+)?-r(?:f)?\s+(?:\/\s*$|~\/\s*$|\/(?:home|root|etc|usr|var|boot))|\bwipefs\s+-a\b/i),
|
|
85
|
+
hook('HKS-022', 'Source or Eval from Environment Variable Path', 'HIGH', /\bsource\s+\$\{?\w+\}?\/|\.\s+\$\{?\w+\}?\/|\beval\s+\$\(|\beval\s+`/i),
|
|
86
|
+
hook('HKS-023', 'Known Malicious Campaign IOC', 'CRITICAL', /api\.masscan\.cloud|git-tanstack\.com|@tanstack\/(?:react-table-core|query-core)-[0-9]|ClawHavoc/i, { skipExample: false }),
|
|
87
|
+
hook('HKS-024', 'Agent Transcript Path Access', 'INFO', /CLAUDE_TRANSCRIPT_PATH|CLAUDE_CONTEXT_FILE|AGENT_TRANSCRIPT|\.claude\/conversation|\.claude\/transcript/i, { skipCode: true, confidence: 'MEDIUM' }),
|
|
88
|
+
rule('MCP-002', 'Shell Alias / Environment Manipulation in Skill Definition', 'CRITICAL', 'mcp_injection', /\balias\s+\w+\s*=|\.bash(?:rc|_aliases|_profile)\b|\.zshrc\b|\.profile\b|(?:export|set)\s+PATH\s*=|\bauto.?memory\b|\bmemory\s+poisoning\b/i, { skipExample: true, skipCode: true }),
|
|
89
|
+
rule('MCP-002', 'Git Hook / Config Tampering Pattern', 'CRITICAL', 'mcp_injection', /\.git\/hooks\/|post-checkout|pre-commit\s+hook|post-merge|mcp.*tamper|tamper.*mcp|config.*tamper|sha.256.*hmac|hmac.*snapshot/i, { skipExample: true, skipCode: true, confidence: 'MEDIUM' }),
|
|
90
|
+
rule('MCP-003', 'Hidden Instruction Marker in Tool Description', 'CRITICAL', 'mcp_injection', /<!--[^>]*(?:ignore|override|system|admin|bypass|exfil)[^>]*-->|\[INST\]|\[\/INST\]|<\|(?:system|im_start|im_end)\|>/i, { skipExample: true }),
|
|
91
|
+
rule('MCP-004', 'Risky MCP Server Type — High-Privilege Tool Category', 'HIGH', 'mcp_injection', /"(?:name|type)"\s*:\s*"[^"]*(?:filesystem|file.?system|shell|terminal|command.?exec|puppeteer|playwright|browser|selenium|postgres(?:ql)?|mysql|sqlite|database|db.?manager|slack|discord|email.?sender|smtp)[^"]*"/i, { skipExample: true, confidence: 'MEDIUM' }),
|
|
92
|
+
rule('MCP-012', 'MCP Server Executes Remote Script via curl/wget Pipe', 'CRITICAL', 'mcp_injection', /(?:curl|wget)\s+[^\n|]{5,}\|\s*(?:bash|sh|zsh|python|node)|"(?:curl|wget)"[^}]{0,300}"\|[^"]*(?:bash|sh)"/i, { skipExample: true, relatedAst: 'AST02:2026' }),
|
|
93
|
+
rule('MCP-013', 'Shell Metacharacters in MCP Server Arguments', 'HIGH', 'mcp_injection', /"args"\s*:\s*\[[^\]]*"[^"]*(?:[;&|`]|\$\()[^"]*"/i, { skipExample: true, confidence: 'MEDIUM' }),
|
|
94
|
+
rule('INJ-004', 'Hidden Injection Attempt in HTML Comment', 'CRITICAL', 'prompt_injection', /<!--.*?(?:ignore|override|bypass|jailbreak|disregard|SYSTEM:|DAN).*?-->/i),
|
|
95
|
+
rule('INJ-005', 'LaTeX Hidden Text — Invisible Injection Vector', 'HIGH', 'prompt_injection', /\$\\color\{(?:white|transparent)\}\{[^}]+\}\$/i),
|
|
96
|
+
rule('INJ-006', 'Base64 Decode Call — Obfuscated Instruction Vector', 'HIGH', 'prompt_injection', /\b(?:atob|fromBase64|base64_decode|b64decode)\s*\(/i, { skipExample: true }),
|
|
97
|
+
rule('INJ-006', 'Suspicious Long Base64 String — Potential Obfuscated Instruction', 'MEDIUM', 'prompt_injection', /[A-Za-z0-9+/]{60,}={0,2}/, {
|
|
98
|
+
skipExample: true,
|
|
99
|
+
skipCode: true,
|
|
100
|
+
confidence: 'LOW',
|
|
101
|
+
excludePattern: /https?:\/\/|sha\d+|checksum|hash/i,
|
|
102
|
+
variantId: 'long-base64'
|
|
103
|
+
}),
|
|
104
|
+
rule('INJ-007', 'Misinformation Generation Instruction', 'HIGH', 'prompt_injection', /\b(?:generate|create|write|produce)\s+(?:fake|false|fabricated|misleading|disinformation|misinformation|made.up)\b|\bpretend\s+(?:that|it\s+is\s+true|the\s+following\s+is\s+real)\b|\bspread\s+(?:false|fake|misleading)\b/i, { skipExample: true, confidence: 'MEDIUM' }),
|
|
105
|
+
rule('INJ-008', 'KaTeX / Display-Math Hidden Text', 'HIGH', 'prompt_injection', /\$\$[^$]*\\(?:color|colorbox|pagecolor|textcolor)\s*\{(?:white|transparent|#fff)[^}]*\}|\\(?:colorbox|pagecolor)\s*\{(?:white|transparent|#fff)[^}]*\}/i, { skipExample: true }),
|
|
106
|
+
rule('INJ-009', 'Multi-Layer Base64 Obfuscation', 'HIGH', 'prompt_injection', /\bVm0wd[A-Za-z0-9+/]/, { skipExample: true, skipCode: true, variantId: 'multi-layer-base64' }),
|
|
107
|
+
rule('MD-007', 'Image Tag with javascript: or data: URI', 'CRITICAL', 'markdown_injection', /!\[.*?\]\s*\(\s*(?:javascript:|data:)|<img\b[^>]+src\s*=\s*["']\s*(?:javascript:|data:)/i),
|
|
108
|
+
rule('MD-009', 'vbscript: URI in Markdown Link or Attribute', 'CRITICAL', 'markdown_injection', /\]\s*\(\s*vbscript:|href\s*=\s*["']\s*vbscript:|src\s*=\s*["']\s*vbscript:/i),
|
|
109
|
+
rule('MD-010', 'Repetitive Image Syntax — Potential ReDoS / DoS Trigger', 'MEDIUM', 'markdown_injection', /(?:!\[){20,}/),
|
|
110
|
+
rule('MD-011', 'dangerouslySetInnerHTML Without Sanitization', 'HIGH', 'markdown_injection', /dangerouslySetInnerHTML/i, { skipCode: true, confidence: 'MEDIUM', contextPattern: /DOMPurify|sanitize|rehype-sanitize|xss/i, contextRadius: 5 }),
|
|
111
|
+
rule('MD-013', '.innerHTML Assignment Without Sanitization', 'HIGH', 'markdown_injection', /\.innerHTML\s*=/i, { skipCode: true, confidence: 'MEDIUM', contextPattern: /DOMPurify|sanitize|rehype-sanitize|xss/i, contextRadius: 5 }),
|
|
112
|
+
rule('MD-014', 'HTML Escaping Disabled in Markdown Config', 'HIGH', 'markdown_injection', /(?:escape[_-]?html|sanitize|escapeHtml)\s*[:=]\s*(?:false|0|no|off)\b|html\s*:\s*true\b/i),
|
|
113
|
+
rule('MD-015', 'Meta Refresh Tag — Redirect / Content Exfiltration', 'HIGH', 'markdown_injection', /<meta\b[^>]*http-equiv\s*=\s*["']?refresh/i, { skipCode: true }),
|
|
114
|
+
rule('MD-016', 'Mixed-Quote Link Title — HTML Attribute Injection', 'MEDIUM', 'markdown_injection', /\[[^\]]+\]\([^\s)]+\s+"[^"]*'[^"]*"\)/i, { confidence: 'MEDIUM' }),
|
|
115
|
+
rule('MD-017', 'Image URL Quote Breakout — Event Handler Injection', 'CRITICAL', 'markdown_injection', /!\[[^\]]*\]\([^)]*"\s*on\w+\s*=|<img\b[^>]*src\s*=\s*[^>]*"\s*on\w+\s*=/i),
|
|
116
|
+
rule('MD-018', 'CSS expression() / Style Attribute XSS', 'HIGH', 'markdown_injection', /style\s*=\s*["'][^"']*(?:expression\s*\(|javascript\s*:|url\s*\()/i, { skipCode: true }),
|
|
117
|
+
rule('MD-019', 'target="_blank" Without rel="noopener noreferrer"', 'MEDIUM', 'markdown_injection', /target\s*=\s*["']_blank["']/i, { excludePattern: /noopener/i }),
|
|
118
|
+
rule('MD-021', 'iframe Embedded in Image Syntax', 'HIGH', 'markdown_injection', /!\[[^\]]*\]\s*\([^)]*<\s*iframe/i),
|
|
119
|
+
rule('MD-023', 'Hidden Form Field With Hardcoded Value', 'HIGH', 'markdown_injection', /<input\b(?=[^>]*\btype\s*=\s*(?:"hidden"|'hidden'|hidden(?=\s|\/?>)))(?=[^>]*\bvalue\s*=\s*(?:"[^"]{4,}"|'[^']{4,}'|[^\s>]{4,}))[^>]*>/i, { skipCode: true }),
|
|
120
|
+
rule('MD-022', 'Hidden Input Field in Markdown', 'MEDIUM', 'markdown_injection', /<input\b(?=[^>]*\btype\s*=\s*(?:"hidden"|'hidden'|hidden(?=\s|\/?>)))[^>]*>/i, {
|
|
121
|
+
skipCode: true,
|
|
122
|
+
confidence: 'MEDIUM',
|
|
123
|
+
excludePattern: /<input\b(?=[^>]*\btype\s*=\s*(?:"hidden"|'hidden'|hidden(?=\s|\/?>)))(?=[^>]*\bvalue\s*=\s*(?:"[^"]{4,}"|'[^']{4,}'|[^\s>]{4,}))[^>]*>/i
|
|
124
|
+
}),
|
|
125
|
+
rule('MD-026', '<style> Tag — CSS Injection', 'MEDIUM', 'markdown_injection', /<style\b/i, { skipCode: true }),
|
|
126
|
+
rule('MD-029', 'CSS Hidden Text — Invisible LLM Prompt Injection', 'HIGH', 'prompt_injection', /style\s*=\s*["'][^"']*(?:color\s*:\s*(?:white|#fff(?:fff)?|transparent|rgba?\([^)]*,\s*0\s*\))|opacity\s*:\s*0(?:\.\d+)?(?:\s|;|")|visibility\s*:\s*hidden|display\s*:\s*none)/i, { skipCode: true }),
|
|
127
|
+
rule('MD-030', 'Windows Notepad RCE — Malicious Protocol URI', 'CRITICAL', 'markdown_injection', /(?:<|\[[^\]]+\]\()(?:file:(?:\/|\\\\){4}|ms-appinstaller:(?:\/|\\\\){2})/i),
|
|
128
|
+
rule('MD-031', 'Repetitive Delimiter Run — markdown-it linkify ReDoS', 'MEDIUM', 'markdown_injection', /\*{15,}|_{15,}/, { skipCode: true }),
|
|
129
|
+
rule('MD-033', 'Obfuscated JavaScript URI — Encoding/Whitespace Bypass', 'CRITICAL', 'markdown_injection', /\]\s*\(\s*(?:(?:j|&#[xX]?[0-9a-fA-F]+;)(?:&#[xX]?[0-9a-fA-F]+;|%[0-9a-fA-F]{2})+[a-z]*script\s*:|j\s+a\s+v\s+a\s+s\s+c\s+r\s+i\s+p\s+t\s*:)/i),
|
|
130
|
+
rule('MD-034', 'markdown-it Unsafe highlight Callback', 'HIGH', 'markdown_injection', /\bhighlight\s*:\s*(?:function\b|\(|\w+\s*=>)/i, { skipCode: true, confidence: 'MEDIUM', contextPattern: /escapeHtml|DOMPurify|sanitize/i, contextRadius: 5 }),
|
|
131
|
+
rule('MD-035', 'Media Tag with Event Handler — XSS / Electron RCE', 'HIGH', 'markdown_injection', /<(?:audio|video|source|track)\b[^>]*\bon\w+\s*=/i, { skipCode: true }),
|
|
132
|
+
rule('ASI-004', 'Dynamic or Unverified Tool / Plugin Loading', 'HIGH', 'agentic_supply_chain', /\bdynamic(?:ally)?\s+(?:load|import|register|install)\s+(?:tool|plugin|agent|extension|skill)\b|\btrust\s+(?:all|any)\s+(?:agents?|tools?|plugins?|mcp\s+servers?)\b|\bopen\s+(?:agent\s+)?registry\b|\bno\s+(?:tool|agent|plugin)\s+(?:verification|validation|allowlist|whitelist)\b|\baccept\s+(?:any|all)\s+(?:mcp|tool|agent)\s+(?:connections?|registrations?|descriptors?)\b/i, { skipExample: true, confidence: 'MEDIUM' }),
|
|
133
|
+
rule('ASI-006', 'Unsafe Memory or Context Persistence Pattern', 'HIGH', 'memory_poisoning', /\bauto(?:matically)?\s+(?:store|save|memorize|ingest|add)\s+(?:all\s+)?(?:output|response|result|generated\s+content)\b|\bno\s+(?:memory|context)\s+(?:validation|sanitization|isolation|segmentation)\b|\breuse\s+(?:memory|context|session|embeddings?)\s+across\s+(?:users?|sessions?|tenants?|agents?)\b|\bpersist\s+(?:all\s+)?(?:user\s+)?(?:data|inputs?|messages?|outputs?)\s+(?:to|in)\s+(?:memory|store|database|rag)\b/i, { skipExample: true, confidence: 'MEDIUM' }),
|
|
134
|
+
rule('ASI-007', 'Insecure Inter-Agent Communication Pattern', 'HIGH', 'insecure_agent_comm', /(?:communicate|connect|send|receive)\s+(?:with\s+)?(?:other\s+)?agents?\s+(?:via|over|using)\s+http:\/\/|\btrust\s+(?:all\s+)?(?:internal|inbound)\s+(?:agent|inter.?agent)\s+(?:messages?|requests?|commands?)\b|\bno\s+(?:authentication|verification|signature|validation)\s+(?:for|on|of)\s+(?:agent|inter.?agent|internal)\s+(?:messages?|comms?|requests?)\b|\baccept\s+(?:all|any)\s+(?:agent|mcp|a2a)\s+(?:messages?|requests?|instructions?)\b/i, { skipExample: true, confidence: 'MEDIUM' }),
|
|
135
|
+
rule('ASI-008', 'Cascading Failure Risk — Unbounded Delegation or Broadcast', 'MEDIUM', 'cascading_failure', /\bbroadcast\s+(?:to\s+all|across\s+all)\s+(?:agents?|instances?|nodes?)\b|\bpropagate\s+(?:errors?|failures?|changes?|results?)\s+(?:to\s+all|automatically|across\s+all)\b|\bno\s+circuit\s+breaker\b|\bunlimited\s+(?:delegation|recursion|depth)\s*(?:\s+of\s+)?(?:agent|task|call)?\b|\bautomatically\s+(?:delegate|forward|escalate)\s+(?:all|any)\s+(?:tasks?|requests?|failures?)\b/i, { skipExample: true, confidence: 'MEDIUM' }),
|
|
136
|
+
rule('ASI-009', 'Human-Agent Trust Exploitation Pattern', 'HIGH', 'trust_exploitation', /\b(?:urgent|critical|emergency)\s+action\s+required\b|\byou\s+(?:must|need\s+to|have\s+to)\s+(?:act|approve|trust|comply)\s+(?:now|immediately|right\s+away)\b|\bno\s+need\s+to\s+(?:verify|check|review|confirm)\b|\byou\s+can\s+(?:fully\s+)?trust\s+(?:this|me|the\s+(?:agent|system|assistant))\b|\bdon['’]?t\s+(?:question|doubt|verify)\s+(?:the\s+)?(?:agent|system|assistant|results?)\b/i, { skipExample: true, confidence: 'MEDIUM' }),
|
|
137
|
+
rule('ASI-010', 'Rogue Agent Behavior Pattern — Self-Replication or Persistence', 'CRITICAL', 'rogue_agent', /\bspawn\s+(?:new|additional|extra|more)\s+(?:agents?|instances?|copies?|replicas?)\b|\bcreate\s+(?:a\s+)?(?:copy|replica|clone)\s+of\s+(?:yourself|itself|this\s+agent|the\s+agent)\b|\bself.?replicate?\b|\bpropagate\s+(?:yourself|itself|this\s+agent|this\s+skill)\b|\bpersist\s+(?:across|after|beyond)\s+(?:shutdown|restart|termination)\b/i, { skipExample: true, confidence: 'MEDIUM' }),
|
|
138
|
+
rule('LLM-008', 'Excessive Agency — Destructive Action Without Human Approval', 'HIGH', 'excessive_agency', /without\s+(?:asking|confirmation|approval|review|permission)|(?:automatically|autonomously|silently)\s+(?:delete|remove|overwrite|execute|send|deploy|publish)/i, { skipExample: true, confidence: 'MEDIUM' })
|
|
139
|
+
];
|
|
140
|
+
exports.HIGH_IMPACT_DOCUMENT_RULES = [
|
|
141
|
+
rule('MD-012', 'rehype-raw Without rehype-sanitize', 'HIGH', 'markdown_injection', /rehype-raw/i, { confidence: 'MEDIUM' }),
|
|
142
|
+
rule('MD-027', 'Markdown Renderer Unsafe HTML Config', 'HIGH', 'markdown_injection', /unsafe\s*:\s*true|ignoreLogs\s*=.*warning-goldmark-raw-html/i),
|
|
143
|
+
rule('MD-028', 'remark-html Without Sanitization', 'HIGH', 'markdown_injection', /\bremark-html\b|remarkHtml/i, { confidence: 'MEDIUM', excludePattern: /sanitize|DOMPurify|rehype-sanitize/i }),
|
|
144
|
+
rule('MD-032', 'Math Block HTML/Script Injection', 'HIGH', 'markdown_injection', /\$\$[^$]*?(?:<(?:script|iframe|img|svg|object|embed)\b|on\w+\s*=|javascript:|data:text\/html)[^$]*?\$\$/i)
|
|
145
|
+
];
|
|
146
|
+
exports.INFORMATIONAL_CONTROL_RULES = [
|
|
147
|
+
rule('CTL-002', 'No Input Validation / Sanitization Instruction', 'INFO', 'missing_control', /(?:sanitiz|validat|filter|clean)\s+(?:all\s+)?(?:user\s+)?input/i),
|
|
148
|
+
rule('CTL-003', 'No Output Filtering / Sanitization Instruction', 'INFO', 'missing_control', /(?:sanitiz|filter|escap|encod)\s+(?:all\s+)?(?:output|response)|output\s+(?:filtering|sanitization|validation)/i),
|
|
149
|
+
rule('CTL-004', 'No Rate Limiting Instruction', 'INFO', 'missing_control', /rate\s*limit|throttl|max\s+requests?|requests?\s+per\s+(?:second|minute|hour)/i),
|
|
150
|
+
rule('CTL-005', 'No Explicit Scope / Role Constraint', 'INFO', 'missing_control', /(?:only|must)\s+(?:operate|respond|act)\s+(?:within|on)\s+.{0,40}|scope\s*[=:]\s*|restrict(?:ed)?\s+to\s+/i),
|
|
151
|
+
rule('CTL-006', 'No Bias Mitigation Instruction', 'INFO', 'missing_control', /(?:avoid|prevent|mitigat)\s+bias|(?:gender|racial|cultural|socioeconomic)\s+(?:neutral|inclusive|fair)|do\s+not\s+(?:assume|stereotype|discriminate)|treat\s+all\s+(?:users?|people|individuals)\s+equally/i),
|
|
152
|
+
rule('CTL-007', 'No Harmful Content Safeguard', 'INFO', 'missing_control', /(?:refuse|reject|do\s+not\s+(?:generate|produce|create))\s+.{0,30}(?:harmful|dangerous|violent|illegal|inappropriate)\s+content|safety\s+(?:guideline|constraint|filter)|responsible\s+AI|content\s+policy/i),
|
|
153
|
+
rule('CTL-008', 'No Memory Segmentation / Isolation Instruction', 'INFO', 'missing_control', /memory\s+(?:segm|isolat|partition|scope)|(?:isolat|segm|partition)\w*\s+memory|per.?(?:session|user|tenant)\s+memory|memory\s+(?:clear|wipe|flush)\s+(?:between|after|per)|separate\s+memory\s+(?:per|by|for)/i),
|
|
154
|
+
rule('CTL-009', 'No Inter-Agent Authentication Instruction', 'INFO', 'missing_control', /(?:mutual|bidirectional)\s+auth|mTLS|client\s+certificate|sign(?:ed)?\s+(?:messages?|requests?|tokens?|agent\s+card)|authenticat\w*\s+(?:agent|inter.?agent|peer)\s+(?:messages?|requests?|calls?)|agent\s+(?:identity|credential)\s+(?:verification|validation|attestation)/i),
|
|
155
|
+
rule('CTL-010', 'No Behavioral Monitoring / Audit Logging Instruction', 'INFO', 'missing_control', /behav(?:ior(?:al)?|iour(?:al)?)\s+(?:monitor|detect|log|audit|baseline)|audit\s+(?:log|trail|record)|immutable\s+log|anomaly\s+detect|(?:log|record|monitor)\s+(?:all\s+)?(?:agent\s+)?(?:actions?|tool\s+(?:calls?|invocations?)|decisions?)/i),
|
|
156
|
+
rule('CTL-011', 'No Indirect Injection Defense', 'INFO', 'missing_control', /(?:external|fetched|retrieved|third.?party|tool.?output|document|web|url)\s+.{0,30}(?:untrusted|unverified|potentially\s+(?:malicious|adversarial))|indirect\s+.{0,10}(?:inject|prompt)|treat\s+.{0,30}(?:external|fetched|retrieved)\s+.{0,20}(?:as\s+(?:untrusted|data))/i),
|
|
157
|
+
rule('CTL-012', 'No Multi-Language Bypass Defense', 'INFO', 'missing_control', /(?:regardless\s+of\s+(?:the\s+)?language|in\s+(?:any|all|every)\s+language|translat\w+\s+.{0,30}(?:rule|instruction|safety|restrict)|language\s+.{0,20}(?:bypass|circumvent|evade)|apply\s+.{0,20}(?:rules?|restrictions?|safeguards?)\s+.{0,20}language)/i),
|
|
158
|
+
rule('CTL-013', 'No Context Overflow / Token Window Defense', 'INFO', 'missing_control', /(?:context|token|input)\s+.{0,20}(?:limit|overflow|window|length|maximum|exceed|truncat)|too\s+(?:long|large|many)\s+.{0,20}(?:input|token|message)|reject\s+.{0,30}(?:oversized|long|large)\s+(?:input|message|request)/i)
|
|
159
|
+
];
|
|
160
|
+
//# sourceMappingURL=high-impact-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"high-impact-rules.js","sourceRoot":"","sources":["../../../src/domain/security/high-impact-rules.ts"],"names":[],"mappings":";;;AA4BA,MAAM,IAAI,GAAG,CACX,EAAU,EACV,KAAa,EACb,QAA0B,EAC1B,QAAgB,EAChB,OAAe,EACf,UAAuG,EAAE,EACjF,EAAE,CAAC,CAAC;IAC5B,EAAE;IACF,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,UAAU,EAAE,MAAM;IAClB,GAAG,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I,CAAC,SAAS,EAAE,sDAAsD,EAAE,MAAM,EAAE,iBAAiB,EAC/F,gPAAgP,CAAC;IACnP,IAAI,CAAC,SAAS,EAAE,+BAA+B,EAAE,MAAM,EAAE,iBAAiB,EACxE,6QAA6Q,CAAC;IAChR,IAAI,CAAC,SAAS,EAAE,kCAAkC,EAAE,MAAM,EAAE,iBAAiB,EAC3E,4PAA4P,CAAC;IAC/P,IAAI,CAAC,SAAS,EAAE,4CAA4C,EAAE,MAAM,EAAE,iBAAiB,EACrF,2NAA2N,CAAC;CAC/N,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Public security-domain exports. */
|
|
2
|
+
export * from './types';
|
|
3
|
+
export * from './fingerprint';
|
|
4
|
+
export * from './markdown-context';
|
|
5
|
+
export * from './policy';
|
|
6
|
+
export * from './suppression';
|
|
7
|
+
export * from './remediations';
|
|
8
|
+
export * from './rule-engine';
|
|
9
|
+
export * from './rating';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain/security/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/** Public security-domain exports. */
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./fingerprint"), exports);
|
|
20
|
+
__exportStar(require("./markdown-context"), exports);
|
|
21
|
+
__exportStar(require("./policy"), exports);
|
|
22
|
+
__exportStar(require("./suppression"), exports);
|
|
23
|
+
__exportStar(require("./remediations"), exports);
|
|
24
|
+
__exportStar(require("./rule-engine"), exports);
|
|
25
|
+
__exportStar(require("./rating"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/security/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sCAAsC;AACtC,0CAAwB;AACxB,gDAA8B;AAC9B,qDAAmC;AACnC,2CAAyB;AACzB,gDAA8B;AAC9B,iDAA+B;AAC/B,gDAA8B;AAC9B,2CAAyB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown parsing context shared by security rules.
|
|
3
|
+
* @module domain/security/markdown-context
|
|
4
|
+
*/
|
|
5
|
+
import type { ParsedSecurityDocument, SecurityArtifactClass } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Parse frontmatter, code-block, section, and artifact classification context.
|
|
8
|
+
* @param content
|
|
9
|
+
*/
|
|
10
|
+
export declare const parseSecurityDocument: (content: string) => ParsedSecurityDocument;
|
|
11
|
+
/**
|
|
12
|
+
* Classify an artifact using the reference scanner's precedence rules.
|
|
13
|
+
* @param content
|
|
14
|
+
* @param frontmatter
|
|
15
|
+
*/
|
|
16
|
+
export declare const classifySecurityArtifact: (content: string, frontmatter: string) => SecurityArtifactClass;
|
|
17
|
+
//# sourceMappingURL=markdown-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-context.d.ts","sourceRoot":"","sources":["../../../src/domain/security/markdown-context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAIjB;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,MAAM,KAAG,sBA+CvD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAI,SAAS,MAAM,EAAE,aAAa,MAAM,KAAG,qBAW/E,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.classifySecurityArtifact = exports.parseSecurityDocument = void 0;
|
|
4
|
+
const EXAMPLE_SECTION = /example|attack|demo|test|vulnerable|bad[ -]?practice|do[ -]?not[ -]?use|❌/i;
|
|
5
|
+
/**
|
|
6
|
+
* Parse frontmatter, code-block, section, and artifact classification context.
|
|
7
|
+
* @param content
|
|
8
|
+
*/
|
|
9
|
+
const parseSecurityDocument = (content) => {
|
|
10
|
+
const rawLines = content.split(/\r\n|\n|\r/);
|
|
11
|
+
let frontmatter = '';
|
|
12
|
+
let bodyStart = 0;
|
|
13
|
+
if (rawLines[0]?.trim() === '---') {
|
|
14
|
+
const end = rawLines.slice(1).findIndex((line) => ['---', '...'].includes(line.trim()));
|
|
15
|
+
if (end !== -1) {
|
|
16
|
+
const endIndex = end + 1;
|
|
17
|
+
frontmatter = rawLines.slice(1, endIndex).join('\n');
|
|
18
|
+
bodyStart = endIndex + 1;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
let inCodeBlock = false;
|
|
22
|
+
let fenceCharacter = '';
|
|
23
|
+
let fenceLength = 0;
|
|
24
|
+
let section = '';
|
|
25
|
+
let inExample = false;
|
|
26
|
+
const lines = rawLines.map((text) => {
|
|
27
|
+
const fence = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(text);
|
|
28
|
+
if (!inCodeBlock && fence !== null && !(fence[1][0] === '`' && fence[2].includes('`'))) {
|
|
29
|
+
inCodeBlock = true;
|
|
30
|
+
fenceCharacter = fence[1][0];
|
|
31
|
+
fenceLength = fence[1].length;
|
|
32
|
+
}
|
|
33
|
+
else if (inCodeBlock) {
|
|
34
|
+
const closingFence = new RegExp(`^ {0,3}\\${fenceCharacter}{${fenceLength},}[ \\t]*$`);
|
|
35
|
+
if (closingFence.test(text)) {
|
|
36
|
+
inCodeBlock = false;
|
|
37
|
+
fenceCharacter = '';
|
|
38
|
+
fenceLength = 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (!inCodeBlock && text.trimStart().startsWith('#')) {
|
|
42
|
+
section = text.trimStart().replace(/^#+/, '').trim();
|
|
43
|
+
inExample = EXAMPLE_SECTION.test(section);
|
|
44
|
+
}
|
|
45
|
+
return { text, section, inExample, inCodeBlock };
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
content,
|
|
49
|
+
frontmatter,
|
|
50
|
+
bodyStart,
|
|
51
|
+
lines,
|
|
52
|
+
artifactClass: (0, exports.classifySecurityArtifact)(content, frontmatter)
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
exports.parseSecurityDocument = parseSecurityDocument;
|
|
56
|
+
/**
|
|
57
|
+
* Classify an artifact using the reference scanner's precedence rules.
|
|
58
|
+
* @param content
|
|
59
|
+
* @param frontmatter
|
|
60
|
+
*/
|
|
61
|
+
const classifySecurityArtifact = (content, frontmatter) => {
|
|
62
|
+
if (/^name:\s*\S+/m.test(frontmatter) && /^description\s*:/m.test(frontmatter)) {
|
|
63
|
+
return 'skill';
|
|
64
|
+
}
|
|
65
|
+
if (/\{\{[^}]+\}\}|<user_input>|\[PLACEHOLDER\]/.test(content)) {
|
|
66
|
+
return 'prompt_template';
|
|
67
|
+
}
|
|
68
|
+
if (/tools?\s*[=:]\s*\[|capabilities?\s*[=:]\s*\[|permissions?\s*[=:]\s*\[|actions?\s*[=:]\s*\[|memory\s*:|max_steps?\s*:/i.test(content)) {
|
|
69
|
+
return 'agent_config';
|
|
70
|
+
}
|
|
71
|
+
return 'general_md';
|
|
72
|
+
};
|
|
73
|
+
exports.classifySecurityArtifact = classifySecurityArtifact;
|
|
74
|
+
//# sourceMappingURL=markdown-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-context.js","sourceRoot":"","sources":["../../../src/domain/security/markdown-context.ts"],"names":[],"mappings":";;;AASA,MAAM,eAAe,GAAG,4EAA4E,CAAC;AAErG;;;GAGG;AACI,MAAM,qBAAqB,GAAG,CAAC,OAAe,EAA0B,EAAE;IAC/E,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC7C,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,KAAK,EAAE,CAAC;QAClC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACxF,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,MAAM,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC;YACzB,WAAW,GAAG,QAAQ,CAAC,KAA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,IAAI,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YACrD,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,WAAW;QACX,SAAS;QACT,KAAK;QACL,aAAa,EAAE,IAAA,gCAAwB,EAAC,OAAO,EAAE,WAAW,CAAC;KAC9D,CAAC;AACJ,CAAC,CAAC;AA/CW,QAAA,qBAAqB,yBA+ChC;AAEF;;;;GAIG;AACI,MAAM,wBAAwB,GAAG,CAAC,OAAe,EAAE,WAAmB,EAAyB,EAAE;IACtG,IAAI,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/E,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,4CAA4C,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/D,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACD,IAAI,uHAAuH,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1I,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAXW,QAAA,wBAAwB,4BAWnC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Security finding severity and gating policy helpers. */
|
|
2
|
+
import type { FailurePolicy, FailurePolicyResult, SecurityFinding, SecuritySeverity } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Return the ordered severities that block a policy.
|
|
5
|
+
* @param findings
|
|
6
|
+
* @param policy
|
|
7
|
+
*/
|
|
8
|
+
export declare const evaluateFailurePolicy: (findings: readonly Pick<SecurityFinding, "severity">[], policy: FailurePolicy) => FailurePolicyResult;
|
|
9
|
+
/**
|
|
10
|
+
* Select findings by an exact severity list.
|
|
11
|
+
* @param findings
|
|
12
|
+
* @param selected
|
|
13
|
+
*/
|
|
14
|
+
export declare const selectSeverities: <T extends {
|
|
15
|
+
severity: SecuritySeverity;
|
|
16
|
+
}>(findings: readonly T[], selected: readonly SecuritySeverity[] | undefined) => T[];
|
|
17
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../src/domain/security/policy.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAOjB;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,UAAU,SAAS,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,EAAE,EACtD,QAAQ,aAAa,KACpB,mBAWF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS;IAAE,QAAQ,EAAE,gBAAgB,CAAA;CAAE,EACvE,UAAU,SAAS,CAAC,EAAE,EACtB,UAAU,SAAS,gBAAgB,EAAE,GAAG,SAAS,KAChD,CAAC,EAAgH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectSeverities = exports.evaluateFailurePolicy = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
const severityRank = (severity) => types_1.SECURITY_SEVERITIES.indexOf(severity);
|
|
6
|
+
/**
|
|
7
|
+
* Return the ordered severities that block a policy.
|
|
8
|
+
* @param findings
|
|
9
|
+
* @param policy
|
|
10
|
+
*/
|
|
11
|
+
const evaluateFailurePolicy = (findings, policy) => {
|
|
12
|
+
if (policy === 'none') {
|
|
13
|
+
return { passed: true, blocking: [] };
|
|
14
|
+
}
|
|
15
|
+
const blocking = policy === 'any'
|
|
16
|
+
? findings.map((finding) => finding.severity)
|
|
17
|
+
: findings.filter((finding) => severityRank(finding.severity) <= severityRank(policy)).map((finding) => finding.severity);
|
|
18
|
+
return {
|
|
19
|
+
passed: blocking.length === 0,
|
|
20
|
+
blocking: [...new Set(blocking)].toSorted((a, b) => severityRank(a) - severityRank(b))
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
exports.evaluateFailurePolicy = evaluateFailurePolicy;
|
|
24
|
+
/**
|
|
25
|
+
* Select findings by an exact severity list.
|
|
26
|
+
* @param findings
|
|
27
|
+
* @param selected
|
|
28
|
+
*/
|
|
29
|
+
const selectSeverities = (findings, selected) => selected === undefined ? [...findings] : findings.filter((finding) => selected.includes(finding.severity));
|
|
30
|
+
exports.selectSeverities = selectSeverities;
|
|
31
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../../src/domain/security/policy.ts"],"names":[],"mappings":";;;AAOA,mCAEiB;AAEjB,MAAM,YAAY,GAAG,CAAC,QAA0B,EAAU,EAAE,CAAC,2BAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEnG;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,CACnC,QAAsD,EACtD,MAAqB,EACA,EAAE;IACvB,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IACxC,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,KAAK,KAAK;QAC/B,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC7C,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5H,OAAO;QACL,MAAM,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC;QAC7B,QAAQ,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;KACvF,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,qBAAqB,yBAchC;AAEF;;;;GAIG;AACI,MAAM,gBAAgB,GAAG,CAC9B,QAAsB,EACtB,QAAiD,EAC5C,EAAE,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAHxG,QAAA,gBAAgB,oBAGwF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the findings of a scan report.
|
|
3
|
+
*
|
|
4
|
+
* Accepts the JSON that scanners write: an object with a `findings` array, or a bare array.
|
|
5
|
+
* Entries that lack a rule id, a file or a known severity are skipped and counted rather than
|
|
6
|
+
* guessed.
|
|
7
|
+
* @module domain/security/rating/findings-document
|
|
8
|
+
*/
|
|
9
|
+
import { type SecurityRatingFinding } from './types';
|
|
10
|
+
export interface ParsedFindings {
|
|
11
|
+
findings: SecurityRatingFinding[];
|
|
12
|
+
/** Entries that were not valid findings. */
|
|
13
|
+
skipped: number;
|
|
14
|
+
/** The `complete` flag of the report when it has one; other scanners omit it. */
|
|
15
|
+
complete?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Turn a parsed JSON document into findings.
|
|
19
|
+
* @param document - Parsed JSON of a scan report
|
|
20
|
+
*/
|
|
21
|
+
export declare const parseFindingsDocument: (document: unknown) => ParsedFindings;
|
|
22
|
+
//# sourceMappingURL=findings-document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findings-document.d.ts","sourceRoot":"","sources":["../../../../src/domain/security/rating/findings-document.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAIL,KAAK,qBAAqB,EAE3B,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,qBAAqB,EAAE,CAAC;IAClC,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAUD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,OAAO,KAAG,cAiCzD,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFindingsDocument = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Read the findings of a scan report.
|
|
6
|
+
*
|
|
7
|
+
* Accepts the JSON that scanners write: an object with a `findings` array, or a bare array.
|
|
8
|
+
* Entries that lack a rule id, a file or a known severity are skipped and counted rather than
|
|
9
|
+
* guessed.
|
|
10
|
+
* @module domain/security/rating/findings-document
|
|
11
|
+
*/
|
|
12
|
+
const types_1 = require("./types");
|
|
13
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
14
|
+
const oneOf = (values, value) => {
|
|
15
|
+
const upper = typeof value === 'string' ? value.toUpperCase() : '';
|
|
16
|
+
return values.find((candidate) => candidate === upper);
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Turn a parsed JSON document into findings.
|
|
20
|
+
* @param document - Parsed JSON of a scan report
|
|
21
|
+
*/
|
|
22
|
+
const parseFindingsDocument = (document) => {
|
|
23
|
+
const entries = Array.isArray(document) ? document : (isRecord(document) && Array.isArray(document.findings) ? document.findings : undefined);
|
|
24
|
+
if (entries === undefined) {
|
|
25
|
+
throw new TypeError('expected an object with a "findings" array, or an array of findings');
|
|
26
|
+
}
|
|
27
|
+
const findings = [];
|
|
28
|
+
let skipped = 0;
|
|
29
|
+
for (const entry of entries) {
|
|
30
|
+
const severity = isRecord(entry) ? oneOf(types_1.SECURITY_RATING_SEVERITIES, entry.severity) : undefined;
|
|
31
|
+
// The security scan report writes snake_case names; other scanners use camelCase.
|
|
32
|
+
const ruleId = isRecord(entry) ? entry.ruleId ?? entry.rule_id : undefined;
|
|
33
|
+
const recommendedFix = isRecord(entry) ? entry.recommendedFix ?? entry.recommended_fix : undefined;
|
|
34
|
+
if (!isRecord(entry) || typeof ruleId !== 'string' || ruleId === '' || typeof entry.file !== 'string' || entry.file === '' || severity === undefined) {
|
|
35
|
+
skipped += 1;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
// A finding without a confidence counts in full: assuming it is doubtful would hide it.
|
|
39
|
+
const confidence = oneOf(types_1.SECURITY_RATING_CONFIDENCES, entry.confidence) ?? 'HIGH';
|
|
40
|
+
findings.push({
|
|
41
|
+
ruleId,
|
|
42
|
+
title: typeof entry.title === 'string' && entry.title !== '' ? entry.title : ruleId,
|
|
43
|
+
severity,
|
|
44
|
+
confidence,
|
|
45
|
+
file: entry.file,
|
|
46
|
+
...(typeof entry.line === 'number' && Number.isInteger(entry.line) ? { line: entry.line } : {}),
|
|
47
|
+
...(typeof recommendedFix === 'string' && recommendedFix !== '' ? { recommendedFix } : {})
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
findings,
|
|
52
|
+
skipped,
|
|
53
|
+
...(isRecord(document) && typeof document.complete === 'boolean' ? { complete: document.complete } : {})
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
exports.parseFindingsDocument = parseFindingsDocument;
|
|
57
|
+
//# sourceMappingURL=findings-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findings-document.js","sourceRoot":"","sources":["../../../../src/domain/security/rating/findings-document.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,mCAMiB;AAUjB,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEvE,MAAM,KAAK,GAAG,CAAmB,MAAoB,EAAE,KAAc,EAAiB,EAAE;IACtF,MAAM,KAAK,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACnE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF;;;GAGG;AACI,MAAM,qBAAqB,GAAG,CAAC,QAAiB,EAAkB,EAAE;IACzE,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC9I,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,SAAS,CAAC,qEAAqE,CAAC,CAAC;IAC7F,CAAC;IACD,MAAM,QAAQ,GAA4B,EAAE,CAAC;IAC7C,IAAI,OAAO,GAAG,CAAC,CAA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AAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/F,GAAG,CAAC,OAAO,cAAc,KAAK,QAAQ,IAAI,cAAc,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3F,CAAC,CAAC;IACL,CAAC;IACD,OAAO;QACL,QAAQ;QACR,OAAO;QACP,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,QAAQ,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzG,CAAC;AACJ,CAAC,CAAC;AAjCW,QAAA,qBAAqB,yBAiChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/domain/security/rating/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./findings-document"), exports);
|
|
19
|
+
__exportStar(require("./scoring"), exports);
|
|
20
|
+
__exportStar(require("./security-rating-report"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/domain/security/rating/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,sDAAoC;AACpC,4CAA0B;AAC1B,2DAAyC"}
|