slopbrick 0.34.10 → 0.35.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/engine/worker.cjs +72 -0
- package/dist/engine/worker.js +72 -0
- package/dist/index.cjs +83 -1
- package/dist/index.js +83 -1
- package/package.json +1 -1
package/dist/engine/worker.cjs
CHANGED
|
@@ -37185,6 +37185,61 @@ var javaSqlStringConcatRule = createRule({
|
|
|
37185
37185
|
}
|
|
37186
37186
|
});
|
|
37187
37187
|
|
|
37188
|
+
// src/rules/java/suspicious-implementation.ts
|
|
37189
|
+
var STRONG_VERB_REGEX = /(?:validate|validates|validated|verifies?|verify|check|checks?|checked|ensures?|ensure|ensured|verifies|verified|sanitize|sanitizes|sanitized|escape|escapes|escaped|authenticate|authenticates|authenticated|authorize|authorizes|authorized|audit|audits|audited|inspect|inspects|inspected|filter|filters?|filtered|normalize|normalizes|normalized|encrypt|encrypts|encrypted|decrypt|decrypts|decrypted|hash|hashes|hashed|sign|signs?|signed|compress|compresses|compressed|decompress|decompresses|decompressed|parse|parses|parsed|format|formats?|formatted)(?=[A-Z]|[^a-zA-Z]|$)/i;
|
|
37190
|
+
var METHOD_DECL_REGEX = /(?:public|private|protected)\s+(?:static\s+)?[\w<>,\s\[\]]+?\s+(\w+)\s*\([^)]*\)\s*\{([^{}]*)\}/g;
|
|
37191
|
+
var EMPTY_BODY_REGEX = /^\s*$/;
|
|
37192
|
+
var RETURN_CONSTANT_REGEX = /^\s*return\s+(?:null|true|false|0|1|0L|0\.0|"")\s*;\s*$/;
|
|
37193
|
+
var RETURN_INPUT_REGEX = /^\s*return\s+(\w+)\s*;\s*$/;
|
|
37194
|
+
var JUST_THROW_REGEX = /^\s*throw\s+new\s+(?:UnsupportedOperationException|UnsupportedOperationException\([^)]*\)|RuntimeException\([^)]*\)|IllegalStateException\([^)]*\))\s*;\s*$/;
|
|
37195
|
+
var javaSuspiciousImplementationRule = createRule({
|
|
37196
|
+
id: "java/suspicious-implementation",
|
|
37197
|
+
category: "security",
|
|
37198
|
+
severity: "high",
|
|
37199
|
+
aiSpecific: false,
|
|
37200
|
+
description: "function name suggests validation/encryption/auth but body is empty or trivially wrong \u2014 content mismatch",
|
|
37201
|
+
create(_context) {
|
|
37202
|
+
return {};
|
|
37203
|
+
},
|
|
37204
|
+
analyze(_context, facts) {
|
|
37205
|
+
const issues = [];
|
|
37206
|
+
const source = facts.v2?._source;
|
|
37207
|
+
if (!source) return issues;
|
|
37208
|
+
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
37209
|
+
if (/\/test\//i.test(facts.filePath) || /\/src\/test\//i.test(facts.filePath)) return issues;
|
|
37210
|
+
let m;
|
|
37211
|
+
METHOD_DECL_REGEX.lastIndex = 0;
|
|
37212
|
+
while ((m = METHOD_DECL_REGEX.exec(source)) !== null) {
|
|
37213
|
+
const methodName = m[1];
|
|
37214
|
+
const body = m[2];
|
|
37215
|
+
if (!STRONG_VERB_REGEX.test(methodName)) continue;
|
|
37216
|
+
let reason = null;
|
|
37217
|
+
if (EMPTY_BODY_REGEX.test(body)) {
|
|
37218
|
+
reason = "empty body";
|
|
37219
|
+
} else if (RETURN_CONSTANT_REGEX.test(body)) {
|
|
37220
|
+
reason = "returns a constant (null/true/false/0/1)";
|
|
37221
|
+
} else if (RETURN_INPUT_REGEX.test(body)) {
|
|
37222
|
+
reason = "returns the input unchanged (pass-through stub)";
|
|
37223
|
+
} else if (JUST_THROW_REGEX.test(body)) {
|
|
37224
|
+
reason = "throws UnsupportedOperationException \u2014 not implemented";
|
|
37225
|
+
}
|
|
37226
|
+
if (!reason) continue;
|
|
37227
|
+
const line = source.slice(0, m.index).split("\n").length;
|
|
37228
|
+
issues.push({
|
|
37229
|
+
ruleId: "java/suspicious-implementation",
|
|
37230
|
+
category: "security",
|
|
37231
|
+
severity: "high",
|
|
37232
|
+
aiSpecific: false,
|
|
37233
|
+
message: `function ${methodName} (${reason}) \u2014 content-based mismatch`,
|
|
37234
|
+
line,
|
|
37235
|
+
column: 1,
|
|
37236
|
+
advice: `The function name "${methodName}" suggests a real validation/encryption/auth/filter operation, but the body is ${reason}. This is a content mismatch \u2014 the code's claimed behavior doesn't match its actual behavior. Real production code that ships this is a silent security failure (OWASP A04:2021 \u2014 Insecure Design). The fix is to either implement the operation or rename the function to reflect what it actually does. Reference: java/suspicious-implementation v0.35.0 (CoCoNUTS-inspired content-based detection).`
|
|
37237
|
+
});
|
|
37238
|
+
}
|
|
37239
|
+
return issues;
|
|
37240
|
+
}
|
|
37241
|
+
});
|
|
37242
|
+
|
|
37188
37243
|
// src/rules/java/system-out-println.ts
|
|
37189
37244
|
var SYSTEM_OUT_REGEX = /\bSystem\.out\.println\s*\(/g;
|
|
37190
37245
|
var REAL_LOGGING_IMPORT_REGEX = /\bimport\s+(?:org\.slf4j\.|org\.apache\.logging\.log4j|org\.apache\.log4j|java\.util\.logging|com\.google\.common\.logging)/;
|
|
@@ -43321,6 +43376,7 @@ var builtinRules = [
|
|
|
43321
43376
|
javaCommandInjectionRule,
|
|
43322
43377
|
javaHardcodedCredentialRule,
|
|
43323
43378
|
javaSqlStringConcatRule,
|
|
43379
|
+
javaSuspiciousImplementationRule,
|
|
43324
43380
|
javaSystemOutPrintlnRule,
|
|
43325
43381
|
javaThreadSleepInLoopRule,
|
|
43326
43382
|
kotlinCoroutineGlobalScopeRule,
|
|
@@ -45710,6 +45766,22 @@ var signal_strength_default = {
|
|
|
45710
45766
|
_v9Precision: 0,
|
|
45711
45767
|
defaultOff: true
|
|
45712
45768
|
},
|
|
45769
|
+
"java/suspicious-implementation": {
|
|
45770
|
+
recall: 0,
|
|
45771
|
+
fpRate: 0,
|
|
45772
|
+
ratio: 0,
|
|
45773
|
+
precision: 0,
|
|
45774
|
+
lastCalibratedAt: "2026-07-03T00:00:00Z",
|
|
45775
|
+
verdict: "OK",
|
|
45776
|
+
_calibrationNote: "v0.35.0: NEW RULE \u2014 content-based detection (CoCoNUTS-inspired). Detects function names that claim a strong operation (validate, encrypt, hash, sanitize, check, verify, authenticate, etc.) but whose body is trivially empty, returns a constant, or returns the input unchanged. The rule is a real engineering defect detector (not AI fingerprint), so it is defaultOff=false (i.e. ON by default) and verdict=OK. The CoCoNUTS paper (2025) showed that style-based AI-detectors fail under paraphrasing; this rule looks at semantic content (function body behavior) rather than surface features. v9 calibration is pending \u2014 the rule was added at the end of the v0.34.X refinement series and has not been measured against the v9 corpus yet. The expected impact: low recall (most production code doesn't have these stubs) but high precision (when it fires, it's a real bug). The full v9 calibration is the next step for v0.35.0.x patches.",
|
|
45777
|
+
aiSpecific: false,
|
|
45778
|
+
_v9Verdict: "OK",
|
|
45779
|
+
_v9Lift: 0,
|
|
45780
|
+
_v9Recall: 0,
|
|
45781
|
+
_v9FpRate: 0,
|
|
45782
|
+
_v9Precision: 0,
|
|
45783
|
+
defaultOff: false
|
|
45784
|
+
},
|
|
45713
45785
|
"swift/force-unwrap": {
|
|
45714
45786
|
recall: 0.10211,
|
|
45715
45787
|
fpRate: 0.21462,
|
package/dist/engine/worker.js
CHANGED
|
@@ -37156,6 +37156,61 @@ var javaSqlStringConcatRule = createRule({
|
|
|
37156
37156
|
}
|
|
37157
37157
|
});
|
|
37158
37158
|
|
|
37159
|
+
// src/rules/java/suspicious-implementation.ts
|
|
37160
|
+
var STRONG_VERB_REGEX = /(?:validate|validates|validated|verifies?|verify|check|checks?|checked|ensures?|ensure|ensured|verifies|verified|sanitize|sanitizes|sanitized|escape|escapes|escaped|authenticate|authenticates|authenticated|authorize|authorizes|authorized|audit|audits|audited|inspect|inspects|inspected|filter|filters?|filtered|normalize|normalizes|normalized|encrypt|encrypts|encrypted|decrypt|decrypts|decrypted|hash|hashes|hashed|sign|signs?|signed|compress|compresses|compressed|decompress|decompresses|decompressed|parse|parses|parsed|format|formats?|formatted)(?=[A-Z]|[^a-zA-Z]|$)/i;
|
|
37161
|
+
var METHOD_DECL_REGEX = /(?:public|private|protected)\s+(?:static\s+)?[\w<>,\s\[\]]+?\s+(\w+)\s*\([^)]*\)\s*\{([^{}]*)\}/g;
|
|
37162
|
+
var EMPTY_BODY_REGEX = /^\s*$/;
|
|
37163
|
+
var RETURN_CONSTANT_REGEX = /^\s*return\s+(?:null|true|false|0|1|0L|0\.0|"")\s*;\s*$/;
|
|
37164
|
+
var RETURN_INPUT_REGEX = /^\s*return\s+(\w+)\s*;\s*$/;
|
|
37165
|
+
var JUST_THROW_REGEX = /^\s*throw\s+new\s+(?:UnsupportedOperationException|UnsupportedOperationException\([^)]*\)|RuntimeException\([^)]*\)|IllegalStateException\([^)]*\))\s*;\s*$/;
|
|
37166
|
+
var javaSuspiciousImplementationRule = createRule({
|
|
37167
|
+
id: "java/suspicious-implementation",
|
|
37168
|
+
category: "security",
|
|
37169
|
+
severity: "high",
|
|
37170
|
+
aiSpecific: false,
|
|
37171
|
+
description: "function name suggests validation/encryption/auth but body is empty or trivially wrong \u2014 content mismatch",
|
|
37172
|
+
create(_context) {
|
|
37173
|
+
return {};
|
|
37174
|
+
},
|
|
37175
|
+
analyze(_context, facts) {
|
|
37176
|
+
const issues = [];
|
|
37177
|
+
const source = facts.v2?._source;
|
|
37178
|
+
if (!source) return issues;
|
|
37179
|
+
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
37180
|
+
if (/\/test\//i.test(facts.filePath) || /\/src\/test\//i.test(facts.filePath)) return issues;
|
|
37181
|
+
let m;
|
|
37182
|
+
METHOD_DECL_REGEX.lastIndex = 0;
|
|
37183
|
+
while ((m = METHOD_DECL_REGEX.exec(source)) !== null) {
|
|
37184
|
+
const methodName = m[1];
|
|
37185
|
+
const body = m[2];
|
|
37186
|
+
if (!STRONG_VERB_REGEX.test(methodName)) continue;
|
|
37187
|
+
let reason = null;
|
|
37188
|
+
if (EMPTY_BODY_REGEX.test(body)) {
|
|
37189
|
+
reason = "empty body";
|
|
37190
|
+
} else if (RETURN_CONSTANT_REGEX.test(body)) {
|
|
37191
|
+
reason = "returns a constant (null/true/false/0/1)";
|
|
37192
|
+
} else if (RETURN_INPUT_REGEX.test(body)) {
|
|
37193
|
+
reason = "returns the input unchanged (pass-through stub)";
|
|
37194
|
+
} else if (JUST_THROW_REGEX.test(body)) {
|
|
37195
|
+
reason = "throws UnsupportedOperationException \u2014 not implemented";
|
|
37196
|
+
}
|
|
37197
|
+
if (!reason) continue;
|
|
37198
|
+
const line = source.slice(0, m.index).split("\n").length;
|
|
37199
|
+
issues.push({
|
|
37200
|
+
ruleId: "java/suspicious-implementation",
|
|
37201
|
+
category: "security",
|
|
37202
|
+
severity: "high",
|
|
37203
|
+
aiSpecific: false,
|
|
37204
|
+
message: `function ${methodName} (${reason}) \u2014 content-based mismatch`,
|
|
37205
|
+
line,
|
|
37206
|
+
column: 1,
|
|
37207
|
+
advice: `The function name "${methodName}" suggests a real validation/encryption/auth/filter operation, but the body is ${reason}. This is a content mismatch \u2014 the code's claimed behavior doesn't match its actual behavior. Real production code that ships this is a silent security failure (OWASP A04:2021 \u2014 Insecure Design). The fix is to either implement the operation or rename the function to reflect what it actually does. Reference: java/suspicious-implementation v0.35.0 (CoCoNUTS-inspired content-based detection).`
|
|
37208
|
+
});
|
|
37209
|
+
}
|
|
37210
|
+
return issues;
|
|
37211
|
+
}
|
|
37212
|
+
});
|
|
37213
|
+
|
|
37159
37214
|
// src/rules/java/system-out-println.ts
|
|
37160
37215
|
var SYSTEM_OUT_REGEX = /\bSystem\.out\.println\s*\(/g;
|
|
37161
37216
|
var REAL_LOGGING_IMPORT_REGEX = /\bimport\s+(?:org\.slf4j\.|org\.apache\.logging\.log4j|org\.apache\.log4j|java\.util\.logging|com\.google\.common\.logging)/;
|
|
@@ -43292,6 +43347,7 @@ var builtinRules = [
|
|
|
43292
43347
|
javaCommandInjectionRule,
|
|
43293
43348
|
javaHardcodedCredentialRule,
|
|
43294
43349
|
javaSqlStringConcatRule,
|
|
43350
|
+
javaSuspiciousImplementationRule,
|
|
43295
43351
|
javaSystemOutPrintlnRule,
|
|
43296
43352
|
javaThreadSleepInLoopRule,
|
|
43297
43353
|
kotlinCoroutineGlobalScopeRule,
|
|
@@ -45681,6 +45737,22 @@ var signal_strength_default = {
|
|
|
45681
45737
|
_v9Precision: 0,
|
|
45682
45738
|
defaultOff: true
|
|
45683
45739
|
},
|
|
45740
|
+
"java/suspicious-implementation": {
|
|
45741
|
+
recall: 0,
|
|
45742
|
+
fpRate: 0,
|
|
45743
|
+
ratio: 0,
|
|
45744
|
+
precision: 0,
|
|
45745
|
+
lastCalibratedAt: "2026-07-03T00:00:00Z",
|
|
45746
|
+
verdict: "OK",
|
|
45747
|
+
_calibrationNote: "v0.35.0: NEW RULE \u2014 content-based detection (CoCoNUTS-inspired). Detects function names that claim a strong operation (validate, encrypt, hash, sanitize, check, verify, authenticate, etc.) but whose body is trivially empty, returns a constant, or returns the input unchanged. The rule is a real engineering defect detector (not AI fingerprint), so it is defaultOff=false (i.e. ON by default) and verdict=OK. The CoCoNUTS paper (2025) showed that style-based AI-detectors fail under paraphrasing; this rule looks at semantic content (function body behavior) rather than surface features. v9 calibration is pending \u2014 the rule was added at the end of the v0.34.X refinement series and has not been measured against the v9 corpus yet. The expected impact: low recall (most production code doesn't have these stubs) but high precision (when it fires, it's a real bug). The full v9 calibration is the next step for v0.35.0.x patches.",
|
|
45748
|
+
aiSpecific: false,
|
|
45749
|
+
_v9Verdict: "OK",
|
|
45750
|
+
_v9Lift: 0,
|
|
45751
|
+
_v9Recall: 0,
|
|
45752
|
+
_v9FpRate: 0,
|
|
45753
|
+
_v9Precision: 0,
|
|
45754
|
+
defaultOff: false
|
|
45755
|
+
},
|
|
45684
45756
|
"swift/force-unwrap": {
|
|
45685
45757
|
recall: 0.10211,
|
|
45686
45758
|
fpRate: 0.21462,
|
package/dist/index.cjs
CHANGED
|
@@ -36,7 +36,7 @@ var VERSION;
|
|
|
36
36
|
var init_header = __esm({
|
|
37
37
|
"src/types/_header.ts"() {
|
|
38
38
|
"use strict";
|
|
39
|
-
VERSION = "0.
|
|
39
|
+
VERSION = "0.35.0";
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
|
|
@@ -30850,6 +30850,68 @@ var init_sql_string_concat = __esm({
|
|
|
30850
30850
|
}
|
|
30851
30851
|
});
|
|
30852
30852
|
|
|
30853
|
+
// src/rules/java/suspicious-implementation.ts
|
|
30854
|
+
var STRONG_VERB_REGEX, METHOD_DECL_REGEX, EMPTY_BODY_REGEX, RETURN_CONSTANT_REGEX, RETURN_INPUT_REGEX, JUST_THROW_REGEX, javaSuspiciousImplementationRule;
|
|
30855
|
+
var init_suspicious_implementation = __esm({
|
|
30856
|
+
"src/rules/java/suspicious-implementation.ts"() {
|
|
30857
|
+
"use strict";
|
|
30858
|
+
init_rule();
|
|
30859
|
+
STRONG_VERB_REGEX = /(?:validate|validates|validated|verifies?|verify|check|checks?|checked|ensures?|ensure|ensured|verifies|verified|sanitize|sanitizes|sanitized|escape|escapes|escaped|authenticate|authenticates|authenticated|authorize|authorizes|authorized|audit|audits|audited|inspect|inspects|inspected|filter|filters?|filtered|normalize|normalizes|normalized|encrypt|encrypts|encrypted|decrypt|decrypts|decrypted|hash|hashes|hashed|sign|signs?|signed|compress|compresses|compressed|decompress|decompresses|decompressed|parse|parses|parsed|format|formats?|formatted)(?=[A-Z]|[^a-zA-Z]|$)/i;
|
|
30860
|
+
METHOD_DECL_REGEX = /(?:public|private|protected)\s+(?:static\s+)?[\w<>,\s\[\]]+?\s+(\w+)\s*\([^)]*\)\s*\{([^{}]*)\}/g;
|
|
30861
|
+
EMPTY_BODY_REGEX = /^\s*$/;
|
|
30862
|
+
RETURN_CONSTANT_REGEX = /^\s*return\s+(?:null|true|false|0|1|0L|0\.0|"")\s*;\s*$/;
|
|
30863
|
+
RETURN_INPUT_REGEX = /^\s*return\s+(\w+)\s*;\s*$/;
|
|
30864
|
+
JUST_THROW_REGEX = /^\s*throw\s+new\s+(?:UnsupportedOperationException|UnsupportedOperationException\([^)]*\)|RuntimeException\([^)]*\)|IllegalStateException\([^)]*\))\s*;\s*$/;
|
|
30865
|
+
javaSuspiciousImplementationRule = createRule({
|
|
30866
|
+
id: "java/suspicious-implementation",
|
|
30867
|
+
category: "security",
|
|
30868
|
+
severity: "high",
|
|
30869
|
+
aiSpecific: false,
|
|
30870
|
+
description: "function name suggests validation/encryption/auth but body is empty or trivially wrong \u2014 content mismatch",
|
|
30871
|
+
create(_context) {
|
|
30872
|
+
return {};
|
|
30873
|
+
},
|
|
30874
|
+
analyze(_context, facts) {
|
|
30875
|
+
const issues = [];
|
|
30876
|
+
const source = facts.v2?._source;
|
|
30877
|
+
if (!source) return issues;
|
|
30878
|
+
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
30879
|
+
if (/\/test\//i.test(facts.filePath) || /\/src\/test\//i.test(facts.filePath)) return issues;
|
|
30880
|
+
let m;
|
|
30881
|
+
METHOD_DECL_REGEX.lastIndex = 0;
|
|
30882
|
+
while ((m = METHOD_DECL_REGEX.exec(source)) !== null) {
|
|
30883
|
+
const methodName = m[1];
|
|
30884
|
+
const body = m[2];
|
|
30885
|
+
if (!STRONG_VERB_REGEX.test(methodName)) continue;
|
|
30886
|
+
let reason = null;
|
|
30887
|
+
if (EMPTY_BODY_REGEX.test(body)) {
|
|
30888
|
+
reason = "empty body";
|
|
30889
|
+
} else if (RETURN_CONSTANT_REGEX.test(body)) {
|
|
30890
|
+
reason = "returns a constant (null/true/false/0/1)";
|
|
30891
|
+
} else if (RETURN_INPUT_REGEX.test(body)) {
|
|
30892
|
+
reason = "returns the input unchanged (pass-through stub)";
|
|
30893
|
+
} else if (JUST_THROW_REGEX.test(body)) {
|
|
30894
|
+
reason = "throws UnsupportedOperationException \u2014 not implemented";
|
|
30895
|
+
}
|
|
30896
|
+
if (!reason) continue;
|
|
30897
|
+
const line = source.slice(0, m.index).split("\n").length;
|
|
30898
|
+
issues.push({
|
|
30899
|
+
ruleId: "java/suspicious-implementation",
|
|
30900
|
+
category: "security",
|
|
30901
|
+
severity: "high",
|
|
30902
|
+
aiSpecific: false,
|
|
30903
|
+
message: `function ${methodName} (${reason}) \u2014 content-based mismatch`,
|
|
30904
|
+
line,
|
|
30905
|
+
column: 1,
|
|
30906
|
+
advice: `The function name "${methodName}" suggests a real validation/encryption/auth/filter operation, but the body is ${reason}. This is a content mismatch \u2014 the code's claimed behavior doesn't match its actual behavior. Real production code that ships this is a silent security failure (OWASP A04:2021 \u2014 Insecure Design). The fix is to either implement the operation or rename the function to reflect what it actually does. Reference: java/suspicious-implementation v0.35.0 (CoCoNUTS-inspired content-based detection).`
|
|
30907
|
+
});
|
|
30908
|
+
}
|
|
30909
|
+
return issues;
|
|
30910
|
+
}
|
|
30911
|
+
});
|
|
30912
|
+
}
|
|
30913
|
+
});
|
|
30914
|
+
|
|
30853
30915
|
// src/rules/java/system-out-println.ts
|
|
30854
30916
|
var SYSTEM_OUT_REGEX, REAL_LOGGING_IMPORT_REGEX, javaSystemOutPrintlnRule;
|
|
30855
30917
|
var init_system_out_println = __esm({
|
|
@@ -46964,6 +47026,7 @@ var init_builtins = __esm({
|
|
|
46964
47026
|
init_command_injection();
|
|
46965
47027
|
init_hardcoded_credential();
|
|
46966
47028
|
init_sql_string_concat();
|
|
47029
|
+
init_suspicious_implementation();
|
|
46967
47030
|
init_system_out_println();
|
|
46968
47031
|
init_thread_sleep_in_loop();
|
|
46969
47032
|
init_coroutine_global_scope();
|
|
@@ -47103,6 +47166,7 @@ var init_builtins = __esm({
|
|
|
47103
47166
|
javaCommandInjectionRule,
|
|
47104
47167
|
javaHardcodedCredentialRule,
|
|
47105
47168
|
javaSqlStringConcatRule,
|
|
47169
|
+
javaSuspiciousImplementationRule,
|
|
47106
47170
|
javaSystemOutPrintlnRule,
|
|
47107
47171
|
javaThreadSleepInLoopRule,
|
|
47108
47172
|
kotlinCoroutineGlobalScopeRule,
|
|
@@ -51797,6 +51861,22 @@ var init_signal_strength = __esm({
|
|
|
51797
51861
|
_v9Precision: 0,
|
|
51798
51862
|
defaultOff: true
|
|
51799
51863
|
},
|
|
51864
|
+
"java/suspicious-implementation": {
|
|
51865
|
+
recall: 0,
|
|
51866
|
+
fpRate: 0,
|
|
51867
|
+
ratio: 0,
|
|
51868
|
+
precision: 0,
|
|
51869
|
+
lastCalibratedAt: "2026-07-03T00:00:00Z",
|
|
51870
|
+
verdict: "OK",
|
|
51871
|
+
_calibrationNote: "v0.35.0: NEW RULE \u2014 content-based detection (CoCoNUTS-inspired). Detects function names that claim a strong operation (validate, encrypt, hash, sanitize, check, verify, authenticate, etc.) but whose body is trivially empty, returns a constant, or returns the input unchanged. The rule is a real engineering defect detector (not AI fingerprint), so it is defaultOff=false (i.e. ON by default) and verdict=OK. The CoCoNUTS paper (2025) showed that style-based AI-detectors fail under paraphrasing; this rule looks at semantic content (function body behavior) rather than surface features. v9 calibration is pending \u2014 the rule was added at the end of the v0.34.X refinement series and has not been measured against the v9 corpus yet. The expected impact: low recall (most production code doesn't have these stubs) but high precision (when it fires, it's a real bug). The full v9 calibration is the next step for v0.35.0.x patches.",
|
|
51872
|
+
aiSpecific: false,
|
|
51873
|
+
_v9Verdict: "OK",
|
|
51874
|
+
_v9Lift: 0,
|
|
51875
|
+
_v9Recall: 0,
|
|
51876
|
+
_v9FpRate: 0,
|
|
51877
|
+
_v9Precision: 0,
|
|
51878
|
+
defaultOff: false
|
|
51879
|
+
},
|
|
51800
51880
|
"swift/force-unwrap": {
|
|
51801
51881
|
recall: 0.10211,
|
|
51802
51882
|
fpRate: 0.21462,
|
|
@@ -60063,6 +60143,8 @@ var RULE_HINTS = {
|
|
|
60063
60143
|
"java/thread-sleep-in-loop": "Use ScheduledExecutorService for periodic work, or BlockingQueue.take() for event-driven work. Thread.sleep in a loop is the polling anti-pattern \u2014 ties up Tomcat/Jetty/Netty threads. (v0.30.0 \u2014 DORMANT, era-confounded ratio 0.97.)",
|
|
60064
60144
|
"java/system-out-println": "The file imports a real logger (SLF4J/Log4j2/java.util.logging) but uses System.out.println. Use the declared log object instead. (v0.31.0 \u2014 OK; ratio 1.73, refined from v0.30.)",
|
|
60065
60145
|
"java/command-injection": "Use ProcessBuilder with a List<String> of args (no shell parsing) and validate each arg. Runtime.exec() with concat is the canonical command-injection pattern. OWASP A03:2021. (v0.30.0 \u2014 DORMANT.)",
|
|
60146
|
+
// v0.35.0 — content-based detection (CoCoNUTS-inspired)
|
|
60147
|
+
"java/suspicious-implementation": "Function name claims validate/encrypt/hash/sanitize but body is empty, returns null/true, or returns the input. This is a content mismatch \u2014 the function's claimed behavior doesn't match its actual behavior. OWASP A04:2021.",
|
|
60066
60148
|
// v0.24.0 — Swift rules (DORMANT until v9 Swift corpus calibration)
|
|
60067
60149
|
"swift/force-unwrap": "Replace with the safe form: `as?` + guard/if let, `try?`, or `guard let x = optional else { return }`. `!` crashes unconditionally in release. (v0.24.0 \u2014 DORMANT.)",
|
|
60068
60150
|
"swift/print-debug": "Replace with `Logger(subsystem:..., category:...).info(...)` (os.log). `print` writes to stdout with no level and no redaction. (v0.24.0 \u2014 DORMANT.)",
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ var VERSION;
|
|
|
19
19
|
var init_header = __esm({
|
|
20
20
|
"src/types/_header.ts"() {
|
|
21
21
|
"use strict";
|
|
22
|
-
VERSION = "0.
|
|
22
|
+
VERSION = "0.35.0";
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
|
|
@@ -30831,6 +30831,68 @@ var init_sql_string_concat = __esm({
|
|
|
30831
30831
|
}
|
|
30832
30832
|
});
|
|
30833
30833
|
|
|
30834
|
+
// src/rules/java/suspicious-implementation.ts
|
|
30835
|
+
var STRONG_VERB_REGEX, METHOD_DECL_REGEX, EMPTY_BODY_REGEX, RETURN_CONSTANT_REGEX, RETURN_INPUT_REGEX, JUST_THROW_REGEX, javaSuspiciousImplementationRule;
|
|
30836
|
+
var init_suspicious_implementation = __esm({
|
|
30837
|
+
"src/rules/java/suspicious-implementation.ts"() {
|
|
30838
|
+
"use strict";
|
|
30839
|
+
init_rule();
|
|
30840
|
+
STRONG_VERB_REGEX = /(?:validate|validates|validated|verifies?|verify|check|checks?|checked|ensures?|ensure|ensured|verifies|verified|sanitize|sanitizes|sanitized|escape|escapes|escaped|authenticate|authenticates|authenticated|authorize|authorizes|authorized|audit|audits|audited|inspect|inspects|inspected|filter|filters?|filtered|normalize|normalizes|normalized|encrypt|encrypts|encrypted|decrypt|decrypts|decrypted|hash|hashes|hashed|sign|signs?|signed|compress|compresses|compressed|decompress|decompresses|decompressed|parse|parses|parsed|format|formats?|formatted)(?=[A-Z]|[^a-zA-Z]|$)/i;
|
|
30841
|
+
METHOD_DECL_REGEX = /(?:public|private|protected)\s+(?:static\s+)?[\w<>,\s\[\]]+?\s+(\w+)\s*\([^)]*\)\s*\{([^{}]*)\}/g;
|
|
30842
|
+
EMPTY_BODY_REGEX = /^\s*$/;
|
|
30843
|
+
RETURN_CONSTANT_REGEX = /^\s*return\s+(?:null|true|false|0|1|0L|0\.0|"")\s*;\s*$/;
|
|
30844
|
+
RETURN_INPUT_REGEX = /^\s*return\s+(\w+)\s*;\s*$/;
|
|
30845
|
+
JUST_THROW_REGEX = /^\s*throw\s+new\s+(?:UnsupportedOperationException|UnsupportedOperationException\([^)]*\)|RuntimeException\([^)]*\)|IllegalStateException\([^)]*\))\s*;\s*$/;
|
|
30846
|
+
javaSuspiciousImplementationRule = createRule({
|
|
30847
|
+
id: "java/suspicious-implementation",
|
|
30848
|
+
category: "security",
|
|
30849
|
+
severity: "high",
|
|
30850
|
+
aiSpecific: false,
|
|
30851
|
+
description: "function name suggests validation/encryption/auth but body is empty or trivially wrong \u2014 content mismatch",
|
|
30852
|
+
create(_context) {
|
|
30853
|
+
return {};
|
|
30854
|
+
},
|
|
30855
|
+
analyze(_context, facts) {
|
|
30856
|
+
const issues = [];
|
|
30857
|
+
const source = facts.v2?._source;
|
|
30858
|
+
if (!source) return issues;
|
|
30859
|
+
if (!/\.java$/i.test(facts.filePath)) return issues;
|
|
30860
|
+
if (/\/test\//i.test(facts.filePath) || /\/src\/test\//i.test(facts.filePath)) return issues;
|
|
30861
|
+
let m;
|
|
30862
|
+
METHOD_DECL_REGEX.lastIndex = 0;
|
|
30863
|
+
while ((m = METHOD_DECL_REGEX.exec(source)) !== null) {
|
|
30864
|
+
const methodName = m[1];
|
|
30865
|
+
const body = m[2];
|
|
30866
|
+
if (!STRONG_VERB_REGEX.test(methodName)) continue;
|
|
30867
|
+
let reason = null;
|
|
30868
|
+
if (EMPTY_BODY_REGEX.test(body)) {
|
|
30869
|
+
reason = "empty body";
|
|
30870
|
+
} else if (RETURN_CONSTANT_REGEX.test(body)) {
|
|
30871
|
+
reason = "returns a constant (null/true/false/0/1)";
|
|
30872
|
+
} else if (RETURN_INPUT_REGEX.test(body)) {
|
|
30873
|
+
reason = "returns the input unchanged (pass-through stub)";
|
|
30874
|
+
} else if (JUST_THROW_REGEX.test(body)) {
|
|
30875
|
+
reason = "throws UnsupportedOperationException \u2014 not implemented";
|
|
30876
|
+
}
|
|
30877
|
+
if (!reason) continue;
|
|
30878
|
+
const line = source.slice(0, m.index).split("\n").length;
|
|
30879
|
+
issues.push({
|
|
30880
|
+
ruleId: "java/suspicious-implementation",
|
|
30881
|
+
category: "security",
|
|
30882
|
+
severity: "high",
|
|
30883
|
+
aiSpecific: false,
|
|
30884
|
+
message: `function ${methodName} (${reason}) \u2014 content-based mismatch`,
|
|
30885
|
+
line,
|
|
30886
|
+
column: 1,
|
|
30887
|
+
advice: `The function name "${methodName}" suggests a real validation/encryption/auth/filter operation, but the body is ${reason}. This is a content mismatch \u2014 the code's claimed behavior doesn't match its actual behavior. Real production code that ships this is a silent security failure (OWASP A04:2021 \u2014 Insecure Design). The fix is to either implement the operation or rename the function to reflect what it actually does. Reference: java/suspicious-implementation v0.35.0 (CoCoNUTS-inspired content-based detection).`
|
|
30888
|
+
});
|
|
30889
|
+
}
|
|
30890
|
+
return issues;
|
|
30891
|
+
}
|
|
30892
|
+
});
|
|
30893
|
+
}
|
|
30894
|
+
});
|
|
30895
|
+
|
|
30834
30896
|
// src/rules/java/system-out-println.ts
|
|
30835
30897
|
var SYSTEM_OUT_REGEX, REAL_LOGGING_IMPORT_REGEX, javaSystemOutPrintlnRule;
|
|
30836
30898
|
var init_system_out_println = __esm({
|
|
@@ -46945,6 +47007,7 @@ var init_builtins = __esm({
|
|
|
46945
47007
|
init_command_injection();
|
|
46946
47008
|
init_hardcoded_credential();
|
|
46947
47009
|
init_sql_string_concat();
|
|
47010
|
+
init_suspicious_implementation();
|
|
46948
47011
|
init_system_out_println();
|
|
46949
47012
|
init_thread_sleep_in_loop();
|
|
46950
47013
|
init_coroutine_global_scope();
|
|
@@ -47084,6 +47147,7 @@ var init_builtins = __esm({
|
|
|
47084
47147
|
javaCommandInjectionRule,
|
|
47085
47148
|
javaHardcodedCredentialRule,
|
|
47086
47149
|
javaSqlStringConcatRule,
|
|
47150
|
+
javaSuspiciousImplementationRule,
|
|
47087
47151
|
javaSystemOutPrintlnRule,
|
|
47088
47152
|
javaThreadSleepInLoopRule,
|
|
47089
47153
|
kotlinCoroutineGlobalScopeRule,
|
|
@@ -51775,6 +51839,22 @@ var init_signal_strength = __esm({
|
|
|
51775
51839
|
_v9Precision: 0,
|
|
51776
51840
|
defaultOff: true
|
|
51777
51841
|
},
|
|
51842
|
+
"java/suspicious-implementation": {
|
|
51843
|
+
recall: 0,
|
|
51844
|
+
fpRate: 0,
|
|
51845
|
+
ratio: 0,
|
|
51846
|
+
precision: 0,
|
|
51847
|
+
lastCalibratedAt: "2026-07-03T00:00:00Z",
|
|
51848
|
+
verdict: "OK",
|
|
51849
|
+
_calibrationNote: "v0.35.0: NEW RULE \u2014 content-based detection (CoCoNUTS-inspired). Detects function names that claim a strong operation (validate, encrypt, hash, sanitize, check, verify, authenticate, etc.) but whose body is trivially empty, returns a constant, or returns the input unchanged. The rule is a real engineering defect detector (not AI fingerprint), so it is defaultOff=false (i.e. ON by default) and verdict=OK. The CoCoNUTS paper (2025) showed that style-based AI-detectors fail under paraphrasing; this rule looks at semantic content (function body behavior) rather than surface features. v9 calibration is pending \u2014 the rule was added at the end of the v0.34.X refinement series and has not been measured against the v9 corpus yet. The expected impact: low recall (most production code doesn't have these stubs) but high precision (when it fires, it's a real bug). The full v9 calibration is the next step for v0.35.0.x patches.",
|
|
51850
|
+
aiSpecific: false,
|
|
51851
|
+
_v9Verdict: "OK",
|
|
51852
|
+
_v9Lift: 0,
|
|
51853
|
+
_v9Recall: 0,
|
|
51854
|
+
_v9FpRate: 0,
|
|
51855
|
+
_v9Precision: 0,
|
|
51856
|
+
defaultOff: false
|
|
51857
|
+
},
|
|
51778
51858
|
"swift/force-unwrap": {
|
|
51779
51859
|
recall: 0.10211,
|
|
51780
51860
|
fpRate: 0.21462,
|
|
@@ -59962,6 +60042,8 @@ var RULE_HINTS = {
|
|
|
59962
60042
|
"java/thread-sleep-in-loop": "Use ScheduledExecutorService for periodic work, or BlockingQueue.take() for event-driven work. Thread.sleep in a loop is the polling anti-pattern \u2014 ties up Tomcat/Jetty/Netty threads. (v0.30.0 \u2014 DORMANT, era-confounded ratio 0.97.)",
|
|
59963
60043
|
"java/system-out-println": "The file imports a real logger (SLF4J/Log4j2/java.util.logging) but uses System.out.println. Use the declared log object instead. (v0.31.0 \u2014 OK; ratio 1.73, refined from v0.30.)",
|
|
59964
60044
|
"java/command-injection": "Use ProcessBuilder with a List<String> of args (no shell parsing) and validate each arg. Runtime.exec() with concat is the canonical command-injection pattern. OWASP A03:2021. (v0.30.0 \u2014 DORMANT.)",
|
|
60045
|
+
// v0.35.0 — content-based detection (CoCoNUTS-inspired)
|
|
60046
|
+
"java/suspicious-implementation": "Function name claims validate/encrypt/hash/sanitize but body is empty, returns null/true, or returns the input. This is a content mismatch \u2014 the function's claimed behavior doesn't match its actual behavior. OWASP A04:2021.",
|
|
59965
60047
|
// v0.24.0 — Swift rules (DORMANT until v9 Swift corpus calibration)
|
|
59966
60048
|
"swift/force-unwrap": "Replace with the safe form: `as?` + guard/if let, `try?`, or `guard let x = optional else { return }`. `!` crashes unconditionally in release. (v0.24.0 \u2014 DORMANT.)",
|
|
59967
60049
|
"swift/print-debug": "Replace with `Logger(subsystem:..., category:...).info(...)` (os.log). `print` writes to stdout with no level and no redaction. (v0.24.0 \u2014 DORMANT.)",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "slopbrick",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Discovered, modeled, and governed repository structure. SlopBrick scans source code, classifies it against 95+ rules in 15 categories, computes 4 scores (aiSlopScore: lower=cleaner, engineeringHygiene, security, repositoryHealth composite), and persists the structure for AI agents and CI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|