@neurcode-ai/cli 0.9.65 → 0.9.66
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/commands/bootstrap-policy.d.ts +29 -0
- package/dist/commands/bootstrap-policy.d.ts.map +1 -0
- package/dist/commands/bootstrap-policy.js +334 -0
- package/dist/commands/bootstrap-policy.js.map +1 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +82 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/quickstart.d.ts +21 -0
- package/dist/commands/quickstart.d.ts.map +1 -0
- package/dist/commands/quickstart.js +178 -0
- package/dist/commands/quickstart.js.map +1 -0
- package/dist/commands/remediate-export.d.ts +31 -0
- package/dist/commands/remediate-export.d.ts.map +1 -0
- package/dist/commands/remediate-export.js +283 -0
- package/dist/commands/remediate-export.js.map +1 -0
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +106 -10
- package/dist/commands/verify.js.map +1 -1
- package/dist/governance/canonical-invariants.d.ts +88 -0
- package/dist/governance/canonical-invariants.d.ts.map +1 -0
- package/dist/governance/canonical-invariants.js +197 -0
- package/dist/governance/canonical-invariants.js.map +1 -0
- package/dist/governance/canonical-ordering.d.ts +76 -0
- package/dist/governance/canonical-ordering.d.ts.map +1 -0
- package/dist/governance/canonical-ordering.js +189 -0
- package/dist/governance/canonical-ordering.js.map +1 -0
- package/dist/governance/canonical-pipeline.d.ts +7 -0
- package/dist/governance/canonical-pipeline.d.ts.map +1 -1
- package/dist/governance/canonical-pipeline.js +184 -16
- package/dist/governance/canonical-pipeline.js.map +1 -1
- package/dist/governance/diff-line-provenance.d.ts +59 -0
- package/dist/governance/diff-line-provenance.d.ts.map +1 -0
- package/dist/governance/diff-line-provenance.js +118 -0
- package/dist/governance/diff-line-provenance.js.map +1 -0
- package/dist/governance/pilot-readiness.d.ts +34 -0
- package/dist/governance/pilot-readiness.d.ts.map +1 -0
- package/dist/governance/pilot-readiness.js +226 -0
- package/dist/governance/pilot-readiness.js.map +1 -0
- package/dist/governance/policy-parity-validator.d.ts +62 -0
- package/dist/governance/policy-parity-validator.d.ts.map +1 -0
- package/dist/governance/policy-parity-validator.js +137 -0
- package/dist/governance/policy-parity-validator.js.map +1 -0
- package/dist/governance/remediation-boundary.d.ts +55 -0
- package/dist/governance/remediation-boundary.d.ts.map +1 -0
- package/dist/governance/remediation-boundary.js +120 -0
- package/dist/governance/remediation-boundary.js.map +1 -0
- package/dist/governance/structural-cache.d.ts +103 -0
- package/dist/governance/structural-cache.d.ts.map +1 -0
- package/dist/governance/structural-cache.js +240 -0
- package/dist/governance/structural-cache.js.map +1 -0
- package/dist/governance/structural-on-diff.d.ts +22 -2
- package/dist/governance/structural-on-diff.d.ts.map +1 -1
- package/dist/governance/structural-on-diff.js +36 -4
- package/dist/governance/structural-on-diff.js.map +1 -1
- package/dist/governance/structural-policy-merge.d.ts +8 -0
- package/dist/governance/structural-policy-merge.d.ts.map +1 -1
- package/dist/governance/structural-policy-merge.js +7 -0
- package/dist/governance/structural-policy-merge.js.map +1 -1
- package/dist/governance/verify-runtime-guard.d.ts +99 -0
- package/dist/governance/verify-runtime-guard.d.ts.map +1 -0
- package/dist/governance/verify-runtime-guard.js +129 -0
- package/dist/governance/verify-runtime-guard.js.map +1 -0
- package/dist/index.js +50 -14
- package/dist/index.js.map +1 -1
- package/dist/intent-engine/repo-classifier.d.ts +64 -0
- package/dist/intent-engine/repo-classifier.d.ts.map +1 -0
- package/dist/intent-engine/repo-classifier.js +178 -0
- package/dist/intent-engine/repo-classifier.js.map +1 -0
- package/dist/structural-rules/index.d.ts +4 -0
- package/dist/structural-rules/index.d.ts.map +1 -1
- package/dist/structural-rules/index.js +18 -1
- package/dist/structural-rules/index.js.map +1 -1
- package/dist/structural-rules/python/PY003-broad-except-clause.d.ts +21 -0
- package/dist/structural-rules/python/PY003-broad-except-clause.d.ts.map +1 -1
- package/dist/structural-rules/python/PY003-broad-except-clause.js +212 -21
- package/dist/structural-rules/python/PY003-broad-except-clause.js.map +1 -1
- package/dist/structural-rules/python/PY011-thread-lifecycle.d.ts +11 -0
- package/dist/structural-rules/python/PY011-thread-lifecycle.d.ts.map +1 -0
- package/dist/structural-rules/python/PY011-thread-lifecycle.js +97 -0
- package/dist/structural-rules/python/PY011-thread-lifecycle.js.map +1 -0
- package/dist/structural-rules/python/PY012-asyncio-run-misuse.d.ts +11 -0
- package/dist/structural-rules/python/PY012-asyncio-run-misuse.d.ts.map +1 -0
- package/dist/structural-rules/python/PY012-asyncio-run-misuse.js +83 -0
- package/dist/structural-rules/python/PY012-asyncio-run-misuse.js.map +1 -0
- package/dist/structural-rules/python/PY013-mutable-default-arg.d.ts +11 -0
- package/dist/structural-rules/python/PY013-mutable-default-arg.d.ts.map +1 -0
- package/dist/structural-rules/python/PY013-mutable-default-arg.js +73 -0
- package/dist/structural-rules/python/PY013-mutable-default-arg.js.map +1 -0
- package/dist/structural-rules/python/PY014-fixed-sleep-retry.d.ts +11 -0
- package/dist/structural-rules/python/PY014-fixed-sleep-retry.d.ts.map +1 -0
- package/dist/structural-rules/python/PY014-fixed-sleep-retry.js +115 -0
- package/dist/structural-rules/python/PY014-fixed-sleep-retry.js.map +1 -0
- package/dist/structural-rules/types.d.ts +12 -0
- package/dist/structural-rules/types.d.ts.map +1 -1
- package/dist/utils/verify-runtime-stability.d.ts +142 -0
- package/dist/utils/verify-runtime-stability.d.ts.map +1 -0
- package/dist/utils/verify-runtime-stability.js +230 -0
- package/dist/utils/verify-runtime-stability.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Repository Classifier (Phase 3 — Repository-Aware Intent Bounding)
|
|
4
|
+
*
|
|
5
|
+
* Deterministic classification of a repository's primary language, framework
|
|
6
|
+
* ecosystem, and dependency archetype from the diff file list alone.
|
|
7
|
+
* No disk I/O, no LLM, no heuristics beyond file path and extension patterns.
|
|
8
|
+
*
|
|
9
|
+
* Used to bound semantic reasoning in the intent matcher so that:
|
|
10
|
+
* - Python repos NEVER emit Express/Zod/React-specific findings
|
|
11
|
+
* - Java repos NEVER emit Node.js-specific findings
|
|
12
|
+
* - TypeScript repos NEVER emit FastAPI/Django-specific findings
|
|
13
|
+
*
|
|
14
|
+
* Output confidence < UNSUPPORTED_THRESHOLD triggers an explicit
|
|
15
|
+
* 'unsupported-reasoning-domain' state rather than guessing.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.classifyRepo = classifyRepo;
|
|
19
|
+
exports.isSignalCompatible = isSignalCompatible;
|
|
20
|
+
// ── Thresholds ────────────────────────────────────────────────────────────────
|
|
21
|
+
/** Below this confidence, emit unsupportedReasoningDomain */
|
|
22
|
+
const UNSUPPORTED_THRESHOLD = 0.4;
|
|
23
|
+
// ── Language detection patterns ───────────────────────────────────────────────
|
|
24
|
+
const LANG_PATTERNS = [
|
|
25
|
+
{ language: 'typescript', pattern: /\.(ts|tsx)$/, weight: 2 },
|
|
26
|
+
{ language: 'javascript', pattern: /\.(js|jsx|mjs|cjs)$/, weight: 1 },
|
|
27
|
+
{ language: 'python', pattern: /\.py$/, weight: 2 },
|
|
28
|
+
{ language: 'java', pattern: /\.java$/, weight: 2 },
|
|
29
|
+
{ language: 'go', pattern: /\.go$/, weight: 2 },
|
|
30
|
+
{ language: 'rust', pattern: /\.rs$/, weight: 2 },
|
|
31
|
+
];
|
|
32
|
+
// ── Dependency archetype detection ────────────────────────────────────────────
|
|
33
|
+
const DEPENDENCY_PATTERNS = [
|
|
34
|
+
{ archetype: 'nodejs', pattern: /(?:^|\/)package\.json$/ },
|
|
35
|
+
{ archetype: 'python', pattern: /(?:^|\/)(?:requirements(?:[-_]\w+)?\.txt|pyproject\.toml|setup\.py|setup\.cfg|Pipfile)$/ },
|
|
36
|
+
{ archetype: 'java', pattern: /(?:^|\/)(?:pom\.xml|build\.gradle(?:\.kts)?)$/ },
|
|
37
|
+
{ archetype: 'go', pattern: /(?:^|\/)go\.mod$/ },
|
|
38
|
+
{ archetype: 'rust', pattern: /(?:^|\/)Cargo\.toml$/ },
|
|
39
|
+
];
|
|
40
|
+
// ── Framework ecosystem detection ─────────────────────────────────────────────
|
|
41
|
+
// Keyed by path/filename patterns found in the diff
|
|
42
|
+
const FRAMEWORK_PATTERNS = [
|
|
43
|
+
{ ecosystem: 'airflow', pattern: /(?:airflow|dags?\/|operators?\/)/ },
|
|
44
|
+
{ ecosystem: 'celery', pattern: /(?:celery|tasks?\.py$|worker\.py$)/ },
|
|
45
|
+
{ ecosystem: 'fastapi', pattern: /(?:fastapi|routers?\/.*\.py$)/ },
|
|
46
|
+
{ ecosystem: 'django', pattern: /(?:django|settings\.py$|urls\.py$|views\.py$|models\.py$)/ },
|
|
47
|
+
{ ecosystem: 'flask', pattern: /(?:flask|app\.py$|blueprints?\/)/ },
|
|
48
|
+
{ ecosystem: 'spring', pattern: /(?:springframework|@SpringBootApplication|Controller\.java$)/ },
|
|
49
|
+
{ ecosystem: 'nextjs', pattern: /(?:pages\/|app\/.*page\.tsx$|next\.config\.)/ },
|
|
50
|
+
{ ecosystem: 'react', pattern: /(?:\.tsx$|components?\/|hooks?\/)/ },
|
|
51
|
+
{ ecosystem: 'express', pattern: /(?:express|router\.(ts|js)$|middleware\.(ts|js)$)/ },
|
|
52
|
+
];
|
|
53
|
+
// ── Domain bounding by language ───────────────────────────────────────────────
|
|
54
|
+
// Maps primaryLanguage → list of intent domains safe to evaluate on that language.
|
|
55
|
+
// '*' means all domains are safe (no bounding applied).
|
|
56
|
+
const LANGUAGE_DOMAIN_BOUNDS = {
|
|
57
|
+
python: ['concurrency', 'observability', 'resilience', 'data-access', 'messaging',
|
|
58
|
+
'orchestration', 'caching', 'ml-inference', 'infrastructure', 'security', 'auth'],
|
|
59
|
+
java: ['concurrency', 'observability', 'resilience', 'data-access', 'messaging',
|
|
60
|
+
'orchestration', 'caching', 'infrastructure', 'security', 'auth', 'api'],
|
|
61
|
+
go: ['concurrency', 'observability', 'resilience', 'data-access', 'messaging',
|
|
62
|
+
'caching', 'infrastructure', 'security', 'auth', 'api'],
|
|
63
|
+
rust: ['concurrency', 'observability', 'resilience', 'caching', 'infrastructure'],
|
|
64
|
+
typescript: [], // all domains allowed
|
|
65
|
+
javascript: [], // all domains allowed
|
|
66
|
+
mixed: [], // all domains allowed (conservative — don't bound a mixed repo)
|
|
67
|
+
unknown: [], // all domains allowed (safe default — don't suppress on uncertainty)
|
|
68
|
+
};
|
|
69
|
+
// ── Classifier ────────────────────────────────────────────────────────────────
|
|
70
|
+
/**
|
|
71
|
+
* Classify a repository from the diff file paths.
|
|
72
|
+
*
|
|
73
|
+
* Deterministic algorithm:
|
|
74
|
+
* 1. Count file extensions → determine primaryLanguage by weighted vote
|
|
75
|
+
* 2. Scan manifest file names → determine dependencyArchetype
|
|
76
|
+
* 3. Scan file paths for framework markers → determine frameworkEcosystem
|
|
77
|
+
* 4. Compute confidence from vote margin
|
|
78
|
+
* 5. Bound semantic domains by primaryLanguage
|
|
79
|
+
*/
|
|
80
|
+
function classifyRepo(diffFiles) {
|
|
81
|
+
const langCounts = {};
|
|
82
|
+
let dependencyArchetype = 'unknown';
|
|
83
|
+
let frameworkEcosystem = 'unknown';
|
|
84
|
+
for (const file of diffFiles) {
|
|
85
|
+
const p = file.path.replace(/\\/g, '/');
|
|
86
|
+
// Language vote
|
|
87
|
+
for (const { language, pattern, weight } of LANG_PATTERNS) {
|
|
88
|
+
if (pattern.test(p)) {
|
|
89
|
+
langCounts[language] = (langCounts[language] ?? 0) + weight;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Dependency archetype (first match wins)
|
|
93
|
+
if (dependencyArchetype === 'unknown') {
|
|
94
|
+
for (const { archetype, pattern } of DEPENDENCY_PATTERNS) {
|
|
95
|
+
if (pattern.test(p)) {
|
|
96
|
+
dependencyArchetype = archetype;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Framework ecosystem (first match wins)
|
|
102
|
+
if (frameworkEcosystem === 'unknown') {
|
|
103
|
+
for (const { ecosystem, pattern } of FRAMEWORK_PATTERNS) {
|
|
104
|
+
if (pattern.test(p)) {
|
|
105
|
+
frameworkEcosystem = ecosystem;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Determine primary language
|
|
112
|
+
const sorted = Object.entries(langCounts)
|
|
113
|
+
.sort((a, b) => b[1] - a[1]);
|
|
114
|
+
let primaryLanguage = 'unknown';
|
|
115
|
+
let confidence = 0;
|
|
116
|
+
if (sorted.length === 0) {
|
|
117
|
+
primaryLanguage = 'unknown';
|
|
118
|
+
confidence = 0;
|
|
119
|
+
}
|
|
120
|
+
else if (sorted.length === 1) {
|
|
121
|
+
primaryLanguage = sorted[0][0];
|
|
122
|
+
confidence = 0.95;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
const top = sorted[0][1];
|
|
126
|
+
const second = sorted[1][1];
|
|
127
|
+
const total = sorted.reduce((s, [, v]) => s + v, 0);
|
|
128
|
+
const dominance = top / total;
|
|
129
|
+
if (dominance >= 0.75) {
|
|
130
|
+
primaryLanguage = sorted[0][0];
|
|
131
|
+
confidence = 0.9;
|
|
132
|
+
}
|
|
133
|
+
else if (dominance >= 0.5) {
|
|
134
|
+
primaryLanguage = sorted[0][0];
|
|
135
|
+
confidence = 0.65;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
primaryLanguage = 'mixed';
|
|
139
|
+
confidence = 0.4;
|
|
140
|
+
}
|
|
141
|
+
// Boost confidence if dependency archetype aligns
|
|
142
|
+
if ((dependencyArchetype === 'python' && primaryLanguage === 'python') ||
|
|
143
|
+
(dependencyArchetype === 'nodejs' && (primaryLanguage === 'typescript' || primaryLanguage === 'javascript')) ||
|
|
144
|
+
(dependencyArchetype === 'java' && primaryLanguage === 'java') ||
|
|
145
|
+
(dependencyArchetype === 'go' && primaryLanguage === 'go')) {
|
|
146
|
+
confidence = Math.min(1.0, confidence + 0.1);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const boundedDomains = LANGUAGE_DOMAIN_BOUNDS[primaryLanguage] ?? [];
|
|
150
|
+
const unsupportedReasoningDomain = confidence < UNSUPPORTED_THRESHOLD;
|
|
151
|
+
return {
|
|
152
|
+
primaryLanguage,
|
|
153
|
+
frameworkEcosystem,
|
|
154
|
+
dependencyArchetype,
|
|
155
|
+
confidence,
|
|
156
|
+
boundedDomains,
|
|
157
|
+
unsupportedReasoningDomain,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Returns true if a component signal key is valid for the given repo classification.
|
|
162
|
+
*
|
|
163
|
+
* Component signals that are TypeScript/JavaScript-specific (zod, express, jwt.sign,
|
|
164
|
+
* bcrypt, etc.) must be suppressed when the primary language is Python, Java, Go, etc.
|
|
165
|
+
*
|
|
166
|
+
* @param signalLanguages Languages this signal applies to (empty = applies to all)
|
|
167
|
+
* @param repo The classified repository
|
|
168
|
+
*/
|
|
169
|
+
function isSignalCompatible(signalLanguages, repo) {
|
|
170
|
+
// If the signal has no language restriction, it applies everywhere
|
|
171
|
+
if (signalLanguages.length === 0)
|
|
172
|
+
return true;
|
|
173
|
+
// If the repo is unknown or mixed, allow all signals (safe default)
|
|
174
|
+
if (repo.primaryLanguage === 'unknown' || repo.primaryLanguage === 'mixed')
|
|
175
|
+
return true;
|
|
176
|
+
return signalLanguages.includes(repo.primaryLanguage);
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=repo-classifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-classifier.js","sourceRoot":"","sources":["../../src/intent-engine/repo-classifier.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAmIH,oCAwFC;AAWD,g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G,CAAC;QACnB,CAAC;QAED,kDAAkD;QAClD,IACE,CAAC,mBAAmB,KAAK,QAAQ,IAAI,eAAe,KAAK,QAAQ,CAAC;YAClE,CAAC,mBAAmB,KAAK,QAAQ,IAAI,CAAC,eAAe,KAAK,YAAY,IAAI,eAAe,KAAK,YAAY,CAAC,CAAC;YAC5G,CAAC,mBAAmB,KAAK,MAAM,IAAI,eAAe,KAAK,MAAM,CAAC;YAC9D,CAAC,mBAAmB,KAAK,IAAI,IAAI,eAAe,KAAK,IAAI,CAAC,EAC1D,CAAC;YACD,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,GAAG,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,MAAM,cAAc,GAAG,sBAAsB,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IACrE,MAAM,0BAA0B,GAAG,UAAU,GAAG,qBAAqB,CAAC;IAEtE,OAAO;QACL,eAAe;QACf,kBAAkB;QAClB,mBAAmB;QACnB,UAAU;QACV,cAAc;QACd,0BAA0B;KAC3B,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,kBAAkB,CAChC,eAAkC,EAClC,IAAwB;IAExB,mEAAmE;IACnE,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9C,oEAAoE;IACpE,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,IAAI,IAAI,CAAC,eAAe,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IACxF,OAAO,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -24,6 +24,10 @@ export { PY007SQLAlchemySessionLeak } from './python/PY007-sqlalchemy-session-le
|
|
|
24
24
|
export { PY008CeleryTaskWithoutRetry } from './python/PY008-celery-task-without-retry';
|
|
25
25
|
export { PY009UnsafePickleDeserialization } from './python/PY009-unsafe-pickle-deserialization';
|
|
26
26
|
export { PY010LeakedAiohttpSession } from './python/PY010-leaked-aiohttp-session';
|
|
27
|
+
export { PY011ThreadLifecycle } from './python/PY011-thread-lifecycle';
|
|
28
|
+
export { PY012AsyncioRunMisuse } from './python/PY012-asyncio-run-misuse';
|
|
29
|
+
export { PY013MutableDefaultArg } from './python/PY013-mutable-default-arg';
|
|
30
|
+
export { PY014FixedSleepRetry } from './python/PY014-fixed-sleep-retry';
|
|
27
31
|
export { SR011EventListenerLeak } from './rules/SR011-event-listener-leak';
|
|
28
32
|
export { SR012PromiseRaceLeak } from './rules/SR012-promise-race-leak';
|
|
29
33
|
export { SR013MissingIdempotencyKey } from './rules/SR013-missing-idempotency-key';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/structural-rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,eAAe,EACf,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,gCAAgC,EAAE,MAAM,8CAA8C,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,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mCAAmC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAGxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAGvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAkChD;;;GAGG;AACH,wBAAgB,iCAAiC,IAAI,oBAAoB,CAsCxE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DS002MissingCorrelationId = exports.DS001SagaRollbackAbsence = exports.SR016UnsafeJSONParse = exports.SR015DanglingAbortController = exports.SR014MutableClosureAsync = exports.SR013MissingIdempotencyKey = exports.SR012PromiseRaceLeak = exports.SR011EventListenerLeak = exports.PY010LeakedAiohttpSession = exports.PY009UnsafePickleDeserialization = exports.PY008CeleryTaskWithoutRetry = exports.PY007SQLAlchemySessionLeak = exports.PY006BlockingIOInAsync = exports.PY005FastAPIWithoutPydantic = exports.PY004SwallowedAsyncException = exports.PY003BroadExceptClause = exports.PY002UnboundedDictSingleton = exports.PY001AsyncioTaskWithoutCancel = exports.SR010RetryStorm = exports.SR009MissingRetryBackoff = exports.SR008BackgroundTaskOrphan = exports.SR007CrossRequestError = exports.SR006FanoutErrorSanitization = exports.SR005HalfOpenProbeGate = exports.SR004RequestBoundaryNoValidation = exports.SR003TimerWithoutCleanup = exports.SR002UnboundedCollection = exports.SR001SwallowedAsyncRejection = exports.applyContextualSeverity = exports.adjustViolationSeverity = exports.classifyFileContext = exports.applySuppressions = exports.parseSuppressionDirectives = exports.StructuralRuleEngine = void 0;
|
|
3
|
+
exports.DS002MissingCorrelationId = exports.DS001SagaRollbackAbsence = exports.SR016UnsafeJSONParse = exports.SR015DanglingAbortController = exports.SR014MutableClosureAsync = exports.SR013MissingIdempotencyKey = exports.SR012PromiseRaceLeak = exports.SR011EventListenerLeak = exports.PY014FixedSleepRetry = exports.PY013MutableDefaultArg = exports.PY012AsyncioRunMisuse = exports.PY011ThreadLifecycle = exports.PY010LeakedAiohttpSession = exports.PY009UnsafePickleDeserialization = exports.PY008CeleryTaskWithoutRetry = exports.PY007SQLAlchemySessionLeak = exports.PY006BlockingIOInAsync = exports.PY005FastAPIWithoutPydantic = exports.PY004SwallowedAsyncException = exports.PY003BroadExceptClause = exports.PY002UnboundedDictSingleton = exports.PY001AsyncioTaskWithoutCancel = exports.SR010RetryStorm = exports.SR009MissingRetryBackoff = exports.SR008BackgroundTaskOrphan = exports.SR007CrossRequestError = exports.SR006FanoutErrorSanitization = exports.SR005HalfOpenProbeGate = exports.SR004RequestBoundaryNoValidation = exports.SR003TimerWithoutCleanup = exports.SR002UnboundedCollection = exports.SR001SwallowedAsyncRejection = exports.applyContextualSeverity = exports.adjustViolationSeverity = exports.classifyFileContext = exports.applySuppressions = exports.parseSuppressionDirectives = exports.StructuralRuleEngine = void 0;
|
|
4
4
|
exports.createDefaultStructuralRuleEngine = createDefaultStructuralRuleEngine;
|
|
5
5
|
var engine_1 = require("./engine");
|
|
6
6
|
Object.defineProperty(exports, "StructuralRuleEngine", { enumerable: true, get: function () { return engine_1.StructuralRuleEngine; } });
|
|
@@ -53,6 +53,14 @@ var PY009_unsafe_pickle_deserialization_1 = require("./python/PY009-unsafe-pickl
|
|
|
53
53
|
Object.defineProperty(exports, "PY009UnsafePickleDeserialization", { enumerable: true, get: function () { return PY009_unsafe_pickle_deserialization_1.PY009UnsafePickleDeserialization; } });
|
|
54
54
|
var PY010_leaked_aiohttp_session_1 = require("./python/PY010-leaked-aiohttp-session");
|
|
55
55
|
Object.defineProperty(exports, "PY010LeakedAiohttpSession", { enumerable: true, get: function () { return PY010_leaked_aiohttp_session_1.PY010LeakedAiohttpSession; } });
|
|
56
|
+
var PY011_thread_lifecycle_1 = require("./python/PY011-thread-lifecycle");
|
|
57
|
+
Object.defineProperty(exports, "PY011ThreadLifecycle", { enumerable: true, get: function () { return PY011_thread_lifecycle_1.PY011ThreadLifecycle; } });
|
|
58
|
+
var PY012_asyncio_run_misuse_1 = require("./python/PY012-asyncio-run-misuse");
|
|
59
|
+
Object.defineProperty(exports, "PY012AsyncioRunMisuse", { enumerable: true, get: function () { return PY012_asyncio_run_misuse_1.PY012AsyncioRunMisuse; } });
|
|
60
|
+
var PY013_mutable_default_arg_1 = require("./python/PY013-mutable-default-arg");
|
|
61
|
+
Object.defineProperty(exports, "PY013MutableDefaultArg", { enumerable: true, get: function () { return PY013_mutable_default_arg_1.PY013MutableDefaultArg; } });
|
|
62
|
+
var PY014_fixed_sleep_retry_1 = require("./python/PY014-fixed-sleep-retry");
|
|
63
|
+
Object.defineProperty(exports, "PY014FixedSleepRetry", { enumerable: true, get: function () { return PY014_fixed_sleep_retry_1.PY014FixedSleepRetry; } });
|
|
56
64
|
// TypeScript rules — extended set
|
|
57
65
|
var SR011_event_listener_leak_1 = require("./rules/SR011-event-listener-leak");
|
|
58
66
|
Object.defineProperty(exports, "SR011EventListenerLeak", { enumerable: true, get: function () { return SR011_event_listener_leak_1.SR011EventListenerLeak; } });
|
|
@@ -100,6 +108,10 @@ const SR015_dangling_abort_controller_2 = require("./rules/SR015-dangling-abort-
|
|
|
100
108
|
const SR016_unsafe_json_parse_2 = require("./rules/SR016-unsafe-json-parse");
|
|
101
109
|
const DS001_saga_rollback_absence_2 = require("./distributed/DS001-saga-rollback-absence");
|
|
102
110
|
const DS002_missing_correlation_id_2 = require("./distributed/DS002-missing-correlation-id");
|
|
111
|
+
const PY011_thread_lifecycle_2 = require("./python/PY011-thread-lifecycle");
|
|
112
|
+
const PY012_asyncio_run_misuse_2 = require("./python/PY012-asyncio-run-misuse");
|
|
113
|
+
const PY013_mutable_default_arg_2 = require("./python/PY013-mutable-default-arg");
|
|
114
|
+
const PY014_fixed_sleep_retry_2 = require("./python/PY014-fixed-sleep-retry");
|
|
103
115
|
/**
|
|
104
116
|
* Creates and returns a pre-configured StructuralRuleEngine with all rules registered.
|
|
105
117
|
* This is the standard way to get a ready-to-use engine.
|
|
@@ -135,6 +147,11 @@ function createDefaultStructuralRuleEngine() {
|
|
|
135
147
|
new SR016_unsafe_json_parse_2.SR016UnsafeJSONParse(),
|
|
136
148
|
new DS001_saga_rollback_absence_2.DS001SagaRollbackAbsence(),
|
|
137
149
|
new DS002_missing_correlation_id_2.DS002MissingCorrelationId(),
|
|
150
|
+
// Python — lifecycle and correctness rules (Phase 4.75)
|
|
151
|
+
new PY011_thread_lifecycle_2.PY011ThreadLifecycle(),
|
|
152
|
+
new PY012_asyncio_run_misuse_2.PY012AsyncioRunMisuse(),
|
|
153
|
+
new PY013_mutable_default_arg_2.PY013MutableDefaultArg(),
|
|
154
|
+
new PY014_fixed_sleep_retry_2.PY014FixedSleepRetry(),
|
|
138
155
|
]);
|
|
139
156
|
return engine;
|
|
140
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/structural-rules/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/structural-rules/index.ts"],"names":[],"mappings":";;;AA0GA,8EAsCC;AAhJD,mCAAgD;AAAvC,8GAAA,oBAAoB,OAAA;AAS7B,+CAGwB;AAFtB,0HAAA,0BAA0B,OAAA;AAC1B,i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EAA6B,EAAE;QACnC,IAAI,4DAA2B,EAAE;QACjC,IAAI,kDAAsB,EAAE;QAC5B,IAAI,8DAA4B,EAAE;QAClC,IAAI,4DAA2B,EAAE;QACjC,IAAI,mDAAsB,EAAE;QAC5B,IAAI,0DAA0B,EAAE;QAChC,IAAI,6DAA2B,EAAE;QACjC,IAAI,sEAAgC,EAAE;QACtC,IAAI,wDAAyB,EAAE;QAC/B,IAAI,kDAAsB,EAAE;QAC5B,IAAI,8CAAoB,EAAE;QAC1B,IAAI,0DAA0B,EAAE;QAChC,IAAI,sDAAwB,EAAE;QAC9B,IAAI,8DAA4B,EAAE;QAClC,IAAI,8CAAoB,EAAE;QAC1B,IAAI,sDAAwB,EAAE;QAC9B,IAAI,wDAAyB,EAAE;QAC/B,wDAAwD;QACxD,IAAI,6CAAoB,EAAE;QAC1B,IAAI,gDAAqB,EAAE;QAC3B,IAAI,kDAAsB,EAAE;QAC5B,IAAI,8CAAoB,EAAE;KAC3B,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
import { StructuralRule, StructuralViolation, RuleLanguage } from '../types';
|
|
2
|
+
export type ExceptionFlowClass = 'swallow' | 'log-only' | 'transformed-rethrow' | 'partial-rethrow';
|
|
3
|
+
/**
|
|
4
|
+
* Strip Python comment lines and string literal regions from source lines.
|
|
5
|
+
*
|
|
6
|
+
* Algorithm (deterministic state machine):
|
|
7
|
+
* - Track whether we are inside a triple-quoted string (""" or ''')
|
|
8
|
+
* - Track whether we are inside a single-quoted string (" or ')
|
|
9
|
+
* - If a line starts with # (after stripping indent) → replace with empty string
|
|
10
|
+
* - Content inside string regions is neutralized (replaced with spaces of same length)
|
|
11
|
+
*
|
|
12
|
+
* This is NOT a full Python tokenizer — it handles the common cases that enable
|
|
13
|
+
* bypass of governance checks while remaining O(n) and dependency-free.
|
|
14
|
+
*/
|
|
15
|
+
export declare function stripCommentsAndStrings(lines: string[]): string[];
|
|
16
|
+
/**
|
|
17
|
+
* Classify the exception-handling flow of an except block body.
|
|
18
|
+
*
|
|
19
|
+
* Input: stripped lines (comments and strings already neutralized).
|
|
20
|
+
* Returns the strictest applicable classification.
|
|
21
|
+
*/
|
|
22
|
+
export declare function classifyExceptionFlow(strippedBodyLines: string[], exceptIndent: number): ExceptionFlowClass;
|
|
2
23
|
export declare class PY003BroadExceptClause implements StructuralRule {
|
|
3
24
|
id: string;
|
|
4
25
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PY003-broad-except-clause.d.ts","sourceRoot":"","sources":["../../../src/structural-rules/python/PY003-broad-except-clause.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"PY003-broad-except-clause.d.ts","sourceRoot":"","sources":["../../../src/structural-rules/python/PY003-broad-except-clause.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAU7E,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GACT,UAAU,GACV,qBAAqB,GACrB,iBAAiB,CAAC;AAEtB;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAsGjE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,iBAAiB,EAAE,MAAM,EAAE,EAC3B,YAAY,EAAE,MAAM,GACnB,kBAAkB,CA6CpB;AAED,qBAAa,sBAAuB,YAAW,cAAc;IAC3D,EAAE,SAAW;IACb,IAAI,SAA2C;IAC/C,SAAS,SAAU;IACnB,QAAQ,EAAG,UAAU,CAAU;IAC/B,SAAS,EAAE,YAAY,EAAE,CAAc;IACvC,WAAW,SACyG;IAEpH,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,mBAAmB,EAAE;CAwFnE"}
|
|
@@ -1,10 +1,194 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PY003BroadExceptClause = void 0;
|
|
4
|
+
exports.stripCommentsAndStrings = stripCommentsAndStrings;
|
|
5
|
+
exports.classifyExceptionFlow = classifyExceptionFlow;
|
|
4
6
|
// Matches: except Exception: or except Exception as e:
|
|
5
7
|
const BROAD_EXCEPT_RE = /^(\s*)except\s+Exception(\s+as\s+\w+)?\s*:/;
|
|
6
|
-
// Logging/reporting call patterns
|
|
8
|
+
// Logging/reporting call patterns — only checked AFTER stripping comments
|
|
7
9
|
const LOGGING_RE = /\b(?:log|logger|logging|error|warn|warning|report|track|capture|sentry|bugsnag|rollbar|print)\s*[\.(]/i;
|
|
10
|
+
/**
|
|
11
|
+
* Strip Python comment lines and string literal regions from source lines.
|
|
12
|
+
*
|
|
13
|
+
* Algorithm (deterministic state machine):
|
|
14
|
+
* - Track whether we are inside a triple-quoted string (""" or ''')
|
|
15
|
+
* - Track whether we are inside a single-quoted string (" or ')
|
|
16
|
+
* - If a line starts with # (after stripping indent) → replace with empty string
|
|
17
|
+
* - Content inside string regions is neutralized (replaced with spaces of same length)
|
|
18
|
+
*
|
|
19
|
+
* This is NOT a full Python tokenizer — it handles the common cases that enable
|
|
20
|
+
* bypass of governance checks while remaining O(n) and dependency-free.
|
|
21
|
+
*/
|
|
22
|
+
function stripCommentsAndStrings(lines) {
|
|
23
|
+
const result = [];
|
|
24
|
+
let inTripleDouble = false; // inside """..."""
|
|
25
|
+
let inTripleSingle = false; // inside '''...'''
|
|
26
|
+
for (const line of lines) {
|
|
27
|
+
const trimmed = line.trimStart();
|
|
28
|
+
// If we are inside a triple-quoted block, look for the closing delimiter
|
|
29
|
+
if (inTripleDouble) {
|
|
30
|
+
const closeIdx = line.indexOf('"""');
|
|
31
|
+
if (closeIdx !== -1) {
|
|
32
|
+
inTripleDouble = false;
|
|
33
|
+
// Neutralize up to and including the closing delimiter
|
|
34
|
+
result.push(' '.repeat(line.length));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
result.push(' '.repeat(line.length));
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (inTripleSingle) {
|
|
42
|
+
const closeIdx = line.indexOf("'''");
|
|
43
|
+
if (closeIdx !== -1) {
|
|
44
|
+
inTripleSingle = false;
|
|
45
|
+
result.push(' '.repeat(line.length));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
result.push(' '.repeat(line.length));
|
|
49
|
+
}
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
// Full-line comment — blank it entirely
|
|
53
|
+
if (trimmed.startsWith('#')) {
|
|
54
|
+
result.push('');
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
// Scan for string/comment delimiters character by character
|
|
58
|
+
let out = '';
|
|
59
|
+
let i = 0;
|
|
60
|
+
let inSingleQ = false;
|
|
61
|
+
let inDoubleQ = false;
|
|
62
|
+
while (i < line.length) {
|
|
63
|
+
const ch = line[i];
|
|
64
|
+
const remaining = line.slice(i);
|
|
65
|
+
if (!inSingleQ && !inDoubleQ) {
|
|
66
|
+
// Check for triple-quote opening
|
|
67
|
+
if (remaining.startsWith('"""')) {
|
|
68
|
+
const rest = line.slice(i + 3);
|
|
69
|
+
const closeInSameLine = rest.indexOf('"""');
|
|
70
|
+
if (closeInSameLine !== -1) {
|
|
71
|
+
// Triple-quote opens and closes on same line — neutralize it
|
|
72
|
+
out += ' '.repeat(3 + closeInSameLine + 3);
|
|
73
|
+
i += 3 + closeInSameLine + 3;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
inTripleDouble = true;
|
|
78
|
+
// Neutralize rest of line
|
|
79
|
+
out += ' '.repeat(line.length - i);
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (remaining.startsWith("'''")) {
|
|
84
|
+
const rest = line.slice(i + 3);
|
|
85
|
+
const closeInSameLine = rest.indexOf("'''");
|
|
86
|
+
if (closeInSameLine !== -1) {
|
|
87
|
+
out += ' '.repeat(3 + closeInSameLine + 3);
|
|
88
|
+
i += 3 + closeInSameLine + 3;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
inTripleSingle = true;
|
|
93
|
+
out += ' '.repeat(line.length - i);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Start of single-line string
|
|
98
|
+
if (ch === '"') {
|
|
99
|
+
inDoubleQ = true;
|
|
100
|
+
out += ' ';
|
|
101
|
+
i++;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (ch === "'") {
|
|
105
|
+
inSingleQ = true;
|
|
106
|
+
out += ' ';
|
|
107
|
+
i++;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
// Inline comment
|
|
111
|
+
if (ch === '#') {
|
|
112
|
+
// Rest of line is comment — stop
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
out += ch;
|
|
116
|
+
}
|
|
117
|
+
else if (inDoubleQ) {
|
|
118
|
+
if (ch === '\\') {
|
|
119
|
+
out += ' ';
|
|
120
|
+
i += 2;
|
|
121
|
+
continue;
|
|
122
|
+
} // escape
|
|
123
|
+
if (ch === '"') {
|
|
124
|
+
inDoubleQ = false;
|
|
125
|
+
}
|
|
126
|
+
out += ' ';
|
|
127
|
+
}
|
|
128
|
+
else if (inSingleQ) {
|
|
129
|
+
if (ch === '\\') {
|
|
130
|
+
out += ' ';
|
|
131
|
+
i += 2;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (ch === "'") {
|
|
135
|
+
inSingleQ = false;
|
|
136
|
+
}
|
|
137
|
+
out += ' ';
|
|
138
|
+
}
|
|
139
|
+
i++;
|
|
140
|
+
}
|
|
141
|
+
result.push(out);
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Classify the exception-handling flow of an except block body.
|
|
147
|
+
*
|
|
148
|
+
* Input: stripped lines (comments and strings already neutralized).
|
|
149
|
+
* Returns the strictest applicable classification.
|
|
150
|
+
*/
|
|
151
|
+
function classifyExceptionFlow(strippedBodyLines, exceptIndent) {
|
|
152
|
+
// Only consider lines that are within the except block's indentation scope
|
|
153
|
+
const blockLines = strippedBodyLines.filter(l => {
|
|
154
|
+
const t = l.trimStart();
|
|
155
|
+
if (t.length === 0)
|
|
156
|
+
return false;
|
|
157
|
+
const indent = l.length - t.length;
|
|
158
|
+
return indent > exceptIndent;
|
|
159
|
+
});
|
|
160
|
+
if (blockLines.length === 0)
|
|
161
|
+
return 'swallow';
|
|
162
|
+
const bodyText = blockLines.join('\n');
|
|
163
|
+
// Detect raise statements — only real Python raise keywords at statement level
|
|
164
|
+
// (not inside strings or comments, already stripped above)
|
|
165
|
+
const RAISE_STMT_RE = /^\s*raise\b/m;
|
|
166
|
+
const hasRaise = RAISE_STMT_RE.test(bodyText);
|
|
167
|
+
// Detect "raise X from e" or "raise NewException(" — transformed rethrow
|
|
168
|
+
const TRANSFORM_RAISE_RE = /^\s*raise\s+\w+\s*(?:\(|from)/m;
|
|
169
|
+
const hasTransformRaise = TRANSFORM_RAISE_RE.test(bodyText);
|
|
170
|
+
// Detect bare "raise" (re-raises current exception)
|
|
171
|
+
const BARE_RAISE_RE = /^\s*raise\s*$/m;
|
|
172
|
+
const hasBareRaise = BARE_RAISE_RE.test(bodyText);
|
|
173
|
+
// Detect conditional raise (raise inside if block at deeper indent)
|
|
174
|
+
const CONDITIONAL_RAISE_RE = /^\s+raise\b/m;
|
|
175
|
+
const hasConditionalRaise = !hasBareRaise && !hasTransformRaise && CONDITIONAL_RAISE_RE.test(bodyText);
|
|
176
|
+
const hasLogging = LOGGING_RE.test(bodyText);
|
|
177
|
+
if (hasBareRaise) {
|
|
178
|
+
// Clean re-raise — not a violation
|
|
179
|
+
return 'partial-rethrow'; // partial because could be log+reraise
|
|
180
|
+
}
|
|
181
|
+
if (hasTransformRaise)
|
|
182
|
+
return 'transformed-rethrow';
|
|
183
|
+
if (hasConditionalRaise)
|
|
184
|
+
return 'partial-rethrow';
|
|
185
|
+
if (!hasRaise && hasLogging)
|
|
186
|
+
return 'log-only';
|
|
187
|
+
if (!hasRaise && !hasLogging)
|
|
188
|
+
return 'swallow';
|
|
189
|
+
// raise present but not bare/transform/conditional — treat as partial
|
|
190
|
+
return 'partial-rethrow';
|
|
191
|
+
}
|
|
8
192
|
class PY003BroadExceptClause {
|
|
9
193
|
id = 'PY003';
|
|
10
194
|
name = 'Broad except clause swallowing errors';
|
|
@@ -22,40 +206,46 @@ class PY003BroadExceptClause {
|
|
|
22
206
|
if (!match)
|
|
23
207
|
continue;
|
|
24
208
|
const exceptIndent = match[1].length;
|
|
25
|
-
// Collect the except block body
|
|
26
|
-
const
|
|
209
|
+
// Collect the raw except block body lines (indented deeper than the except)
|
|
210
|
+
const rawBodyLines = [];
|
|
27
211
|
let j = i + 1;
|
|
28
212
|
while (j < lines.length) {
|
|
29
213
|
const bodyLine = lines[j];
|
|
30
214
|
const bodyTrimmed = bodyLine.trimStart();
|
|
31
215
|
// Empty line — continue collecting
|
|
32
216
|
if (bodyTrimmed.length === 0) {
|
|
217
|
+
rawBodyLines.push(bodyLine);
|
|
33
218
|
j++;
|
|
34
219
|
continue;
|
|
35
220
|
}
|
|
36
|
-
const bodyIndent = bodyLine.length -
|
|
221
|
+
const bodyIndent = bodyLine.length - bodyTrimmed.length;
|
|
37
222
|
// If indent is less than or equal to the except indent, block ended
|
|
38
223
|
if (bodyIndent <= exceptIndent)
|
|
39
224
|
break;
|
|
40
|
-
|
|
225
|
+
rawBodyLines.push(bodyLine);
|
|
41
226
|
j++;
|
|
42
227
|
}
|
|
43
|
-
if (
|
|
228
|
+
if (rawBodyLines.length === 0)
|
|
44
229
|
continue;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
230
|
+
// ── AST-level analysis: strip comments and strings before checking ──
|
|
231
|
+
const strippedLines = stripCommentsAndStrings(rawBodyLines);
|
|
232
|
+
const flowClass = classifyExceptionFlow(strippedLines, exceptIndent);
|
|
233
|
+
// Only violations: swallow and log-only (log without re-raise)
|
|
234
|
+
// transformed-rethrow and partial-rethrow are handled by the engineer
|
|
235
|
+
if (flowClass === 'partial-rethrow' || flowClass === 'transformed-rethrow') {
|
|
49
236
|
continue;
|
|
50
|
-
|
|
51
|
-
if (
|
|
237
|
+
}
|
|
238
|
+
// Bare re-raise check: if bare raise exists in RAW lines (before stripping)
|
|
239
|
+
// this is not a swallow — the stripCommentsAndStrings already handles
|
|
240
|
+
// comment stripping, so we just trust classifyExceptionFlow here.
|
|
241
|
+
if (flowClass !== 'swallow' && flowClass !== 'log-only')
|
|
52
242
|
continue;
|
|
53
|
-
|
|
54
|
-
const nonEmpty = bodyLines
|
|
243
|
+
const nonEmptyNonPass = strippedLines
|
|
55
244
|
.map(l => l.trim())
|
|
56
|
-
.filter(l => l.length > 0 && l !== 'pass'
|
|
57
|
-
|
|
58
|
-
|
|
245
|
+
.filter(l => l.length > 0 && l !== 'pass');
|
|
246
|
+
const confidence = flowClass === 'swallow'
|
|
247
|
+
? (nonEmptyNonPass.length === 0 ? 0.97 : 0.88)
|
|
248
|
+
: 0.82; // log-only
|
|
59
249
|
const evidence = line.slice(0, 120);
|
|
60
250
|
violations.push({
|
|
61
251
|
ruleId: this.id,
|
|
@@ -65,13 +255,14 @@ class PY003BroadExceptClause {
|
|
|
65
255
|
filePath,
|
|
66
256
|
line: i + 1,
|
|
67
257
|
column: exceptIndent + 1,
|
|
68
|
-
evidence
|
|
69
|
-
operationalRisk:
|
|
70
|
-
'
|
|
258
|
+
evidence: `${evidence} [flow:${flowClass}]`,
|
|
259
|
+
operationalRisk: `except Exception: block classified as '${flowClass}'. ` +
|
|
260
|
+
'Catches ALL exceptions (including SystemExit, KeyboardInterrupt, MemoryError) without ' +
|
|
261
|
+
're-raising. Silent failures make debugging impossible and hide operational issues.',
|
|
71
262
|
remediation: 'Either re-raise after handling: `except Exception as e: logger.error(e); raise` ' +
|
|
72
263
|
'or narrow the exception type. Avoid bare `except Exception` without at minimum logging.',
|
|
73
264
|
determinism: 'deterministic-structural',
|
|
74
|
-
confidence
|
|
265
|
+
confidence,
|
|
75
266
|
language: 'python',
|
|
76
267
|
});
|
|
77
268
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PY003-broad-except-clause.js","sourceRoot":"","sources":["../../../src/structural-rules/python/PY003-broad-except-clause.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"PY003-broad-except-clause.js","sourceRoot":"","sources":["../../../src/structural-rules/python/PY003-broad-except-clause.ts"],"names":[],"mappings":";;;AA4BA,0DAsGC;AAQD,sDAgDC;AAxLD,uDAAuD;AACvD,MAAM,eAAe,GAAG,4CAA4C,CAAC;AAErE,0EAA0E;AAC1E,MAAM,UAAU,GAAG,wGAAwG,CAAC;AAU5H;;;;;;;;;;;GAWG;AACH,SAAgB,uBAAuB,CAAC,KAAe;IACrD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,cAAc,GAAG,KAAK,CAAC,CAAC,mBAAmB;IAC/C,IAAI,cAAc,GAAG,KAAK,CAAC,CAAC,mBAAmB;IAE/C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAEjC,yEAAyE;QACzE,IAAI,cAAc,EAAE,CAAC;YACnB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACrC,IAAI,QAAQ,KAAK,CAAC,CAAC,EAAE,CAAC;gBACpB,cAAc,GAAG,KAAK,CAAC;gBACvB,uDAAuD;gBACvD,MAAM,CAAC,IAAI,CAAC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AAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;gBAEpC,UAAU,CAAC,IAAI,CAAC;oBACd,MAAM,EAAE,IAAI,CAAC,EAAE;oBACf,QAAQ,EAAE,IAAI,CAAC,IAAI;oBACnB,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,QAAQ;oBACR,IAAI,EAAE,CAAC,GAAG,CAAC;oBACX,MAAM,EAAE,YAAY,GAAG,CAAC;oBACxB,QAAQ,EAAE,GAAG,QAAQ,UAAU,SAAS,GAAG;oBAC3C,eAAe,EACb,0CAA0C,SAAS,KAAK;wBACxD,wFAAwF;wBACxF,oFAAoF;oBACtF,WAAW,EACT,kFAAkF;wBAClF,yFAAyF;oBAC3F,WAAW,EAAE,0BAA0B;oBACvC,UAAU;oBACV,QAAQ,EAAE,QAAQ;iBACnB,CAAC,CAAC;YACL,CAAC;YAED,OAAO,UAAU,CAAC;QACpB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAjGD,wDAiGC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StructuralRule, StructuralViolation, RuleLanguage } from '../types';
|
|
2
|
+
export declare class PY011ThreadLifecycle implements StructuralRule {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
policyRef: string;
|
|
6
|
+
severity: "BLOCKING";
|
|
7
|
+
languages: RuleLanguage[];
|
|
8
|
+
description: string;
|
|
9
|
+
check(filePath: string, sourceText: string): StructuralViolation[];
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=PY011-thread-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PY011-thread-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/structural-rules/python/PY011-thread-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAmB7E,qBAAa,oBAAqB,YAAW,cAAc;IACzD,EAAE,SAAW;IACb,IAAI,SAAoE;IACxE,SAAS,SAAW;IACpB,QAAQ,EAAG,UAAU,CAAU;IAC/B,SAAS,EAAE,YAAY,EAAE,CAAc;IACvC,WAAW,SAEoE;IAE/E,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,mBAAmB,EAAE;CAuEnE"}
|