pumuki 6.3.123 → 6.3.124
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/core/facts/detectors/astRuleThresholdAudit.test.ts +33 -0
- package/core/facts/detectors/security/index.test.ts +8 -2
- package/core/facts/detectors/security/securityCredentials.test.ts +10 -4
- package/core/facts/detectors/security/securityCredentials.ts +11 -4
- package/core/facts/detectors/text/android.ts +0 -6
- package/core/facts/detectors/text/ios.ts +0 -6
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import test from 'node:test';
|
|
5
|
+
|
|
6
|
+
const detectorFiles = [
|
|
7
|
+
'core/facts/detectors/text/ios.ts',
|
|
8
|
+
'core/facts/detectors/text/android.ts',
|
|
9
|
+
'core/facts/detectors/typescript/index.ts',
|
|
10
|
+
'core/facts/detectors/security/securityCredentials.ts',
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
const forbiddenDecisionThresholds = [
|
|
14
|
+
/typeDeclarations\.length\s*<\s*\d+/,
|
|
15
|
+
/conformingTypes\.length\s*<\s*\d+/,
|
|
16
|
+
/trim\(\)\.length\s*>=\s*\d+/,
|
|
17
|
+
/relatedNodes\.length\s*<\s*\d+/,
|
|
18
|
+
/typedCaseCount\s*>=\s*\d+/,
|
|
19
|
+
/caseNodes\.length\s*<\s*\d+/,
|
|
20
|
+
/branchNodes\.length\s*<\s*\d+/,
|
|
21
|
+
/slice\(0,\s*\d+\)/,
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
test('detectores AST estructurales no usan umbrales internos para decidir skills', () => {
|
|
25
|
+
const violations = detectorFiles.flatMap((filePath) => {
|
|
26
|
+
const content = readFileSync(join(process.cwd(), filePath), 'utf8');
|
|
27
|
+
return forbiddenDecisionThresholds
|
|
28
|
+
.filter((pattern) => pattern.test(content))
|
|
29
|
+
.map((pattern) => `${filePath}: ${pattern.source}`);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
assert.deepEqual(violations, []);
|
|
33
|
+
});
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
hasWeakTokenGenerationWithCryptoRandomUuid,
|
|
16
16
|
} from './index';
|
|
17
17
|
|
|
18
|
-
test('hasHardcodedSecretTokenLiteral detecta literales
|
|
18
|
+
test('hasHardcodedSecretTokenLiteral detecta literales reales en identificadores sensibles', () => {
|
|
19
19
|
const ast = {
|
|
20
20
|
type: 'VariableDeclarator',
|
|
21
21
|
id: { type: 'Identifier', name: 'apiToken' },
|
|
@@ -24,11 +24,17 @@ test('hasHardcodedSecretTokenLiteral detecta literales fuertes en identificadore
|
|
|
24
24
|
const safeAst = {
|
|
25
25
|
type: 'VariableDeclarator',
|
|
26
26
|
id: { type: 'Identifier', name: 'apiToken' },
|
|
27
|
-
init: { type: 'StringLiteral', value: '
|
|
27
|
+
init: { type: 'StringLiteral', value: 'example' },
|
|
28
|
+
};
|
|
29
|
+
const shortRealSecretAst = {
|
|
30
|
+
type: 'VariableDeclarator',
|
|
31
|
+
id: { type: 'Identifier', name: 'apiToken' },
|
|
32
|
+
init: { type: 'StringLiteral', value: 'prod' },
|
|
28
33
|
};
|
|
29
34
|
|
|
30
35
|
assert.equal(hasHardcodedSecretTokenLiteral(ast), true);
|
|
31
36
|
assert.equal(hasHardcodedSecretTokenLiteral(safeAst), false);
|
|
37
|
+
assert.equal(hasHardcodedSecretTokenLiteral(shortRealSecretAst), true);
|
|
32
38
|
});
|
|
33
39
|
|
|
34
40
|
test('hasInsecureTokenGenerationWithMathRandom detecta Math.random en asignacion sensible', () => {
|
|
@@ -11,16 +11,21 @@ import {
|
|
|
11
11
|
hasWeakTokenGenerationWithCryptoRandomUuid,
|
|
12
12
|
} from './securityCredentials';
|
|
13
13
|
|
|
14
|
-
test('hasHardcodedSecretTokenLiteral detecta literal
|
|
14
|
+
test('hasHardcodedSecretTokenLiteral detecta literal real en identificador sensible', () => {
|
|
15
15
|
const hardcodedSecretAst = {
|
|
16
16
|
type: 'VariableDeclarator',
|
|
17
17
|
id: { type: 'Identifier', name: 'apiKey' },
|
|
18
18
|
init: { type: 'StringLiteral', value: 'super-secret-key-123' },
|
|
19
19
|
};
|
|
20
|
-
const
|
|
20
|
+
const placeholderAst = {
|
|
21
21
|
type: 'VariableDeclarator',
|
|
22
22
|
id: { type: 'Identifier', name: 'apiKey' },
|
|
23
|
-
init: { type: 'StringLiteral', value: '
|
|
23
|
+
init: { type: 'StringLiteral', value: 'replace-me' },
|
|
24
|
+
};
|
|
25
|
+
const shortRealSecretAst = {
|
|
26
|
+
type: 'VariableDeclarator',
|
|
27
|
+
id: { type: 'Identifier', name: 'apiKey' },
|
|
28
|
+
init: { type: 'StringLiteral', value: 'prod' },
|
|
24
29
|
};
|
|
25
30
|
const nonSensitiveIdentifierAst = {
|
|
26
31
|
type: 'VariableDeclarator',
|
|
@@ -29,7 +34,8 @@ test('hasHardcodedSecretTokenLiteral detecta literal largo en identificador sens
|
|
|
29
34
|
};
|
|
30
35
|
|
|
31
36
|
assert.equal(hasHardcodedSecretTokenLiteral(hardcodedSecretAst), true);
|
|
32
|
-
assert.equal(hasHardcodedSecretTokenLiteral(
|
|
37
|
+
assert.equal(hasHardcodedSecretTokenLiteral(placeholderAst), false);
|
|
38
|
+
assert.equal(hasHardcodedSecretTokenLiteral(shortRealSecretAst), true);
|
|
33
39
|
assert.equal(hasHardcodedSecretTokenLiteral(nonSensitiveIdentifierAst), false);
|
|
34
40
|
});
|
|
35
41
|
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { collectNodeLineMatches, hasNode, isObject } from '../utils/astHelpers';
|
|
2
2
|
|
|
3
3
|
const sensitiveIdentifierPattern = /(secret|token|password|api[_-]?key)/i;
|
|
4
|
+
const placeholderSecretLiteralPattern =
|
|
5
|
+
/^(?:changeme|change-me|change_me|replace-me|replace_me|todo|tbd|example|sample|dummy|test|testing|placeholder|your[_-]?(?:secret|token|password|api[_-]?key)|xxx+)$/i;
|
|
4
6
|
|
|
5
|
-
const
|
|
7
|
+
const hasCredentialLiteralValue = (value: unknown): boolean => {
|
|
6
8
|
if (!isObject(value)) {
|
|
7
9
|
return false;
|
|
8
10
|
}
|
|
9
11
|
if (value.type === 'StringLiteral') {
|
|
10
|
-
return typeof value.value === 'string' && value.value
|
|
12
|
+
return typeof value.value === 'string' && isCredentialLiteral(value.value);
|
|
11
13
|
}
|
|
12
14
|
if (
|
|
13
15
|
value.type === 'TemplateLiteral' &&
|
|
@@ -17,11 +19,16 @@ const hasStrongLiteralValue = (value: unknown): boolean => {
|
|
|
17
19
|
value.quasis.length === 1
|
|
18
20
|
) {
|
|
19
21
|
const cooked = value.quasis[0]?.value?.cooked;
|
|
20
|
-
return typeof cooked === 'string' && cooked
|
|
22
|
+
return typeof cooked === 'string' && isCredentialLiteral(cooked);
|
|
21
23
|
}
|
|
22
24
|
return false;
|
|
23
25
|
};
|
|
24
26
|
|
|
27
|
+
const isCredentialLiteral = (value: string): boolean => {
|
|
28
|
+
const normalized = value.trim();
|
|
29
|
+
return normalized.length > 0 && !placeholderSecretLiteralPattern.test(normalized);
|
|
30
|
+
};
|
|
31
|
+
|
|
25
32
|
const containsMathRandomCall = (candidate: unknown): boolean => {
|
|
26
33
|
return hasNode(candidate, (value) => {
|
|
27
34
|
if (value.type !== 'CallExpression') {
|
|
@@ -109,7 +116,7 @@ const isHardcodedSecretTokenLiteralNode = (value: Record<string, string | number
|
|
|
109
116
|
if (!sensitiveIdentifierPattern.test(idNode.name as string)) {
|
|
110
117
|
return false;
|
|
111
118
|
}
|
|
112
|
-
return
|
|
119
|
+
return hasCredentialLiteralValue(value.init);
|
|
113
120
|
};
|
|
114
121
|
|
|
115
122
|
const isInsecureTokenGenerationWithMathRandomNode = (value: Record<string, string | number | boolean | bigint | symbol | null | Date | object>): boolean => {
|
|
@@ -699,9 +699,6 @@ export const findKotlinLiskovSubstitutionMatch = (
|
|
|
699
699
|
}
|
|
700
700
|
|
|
701
701
|
const typeDeclarations = parseKotlinTypeDeclarations(source);
|
|
702
|
-
if (typeDeclarations.length < 2) {
|
|
703
|
-
return undefined;
|
|
704
|
-
}
|
|
705
702
|
|
|
706
703
|
const sourceLines = source.split(/\r?\n/);
|
|
707
704
|
|
|
@@ -714,9 +711,6 @@ export const findKotlinLiskovSubstitutionMatch = (
|
|
|
714
711
|
const conformingTypes = typeDeclarations.filter((typeDeclaration) =>
|
|
715
712
|
typeDeclaration.conformances.includes(interfaceDeclaration.name)
|
|
716
713
|
);
|
|
717
|
-
if (conformingTypes.length < 2) {
|
|
718
|
-
continue;
|
|
719
|
-
}
|
|
720
714
|
|
|
721
715
|
for (const memberName of memberNames) {
|
|
722
716
|
let safeType: KotlinTypeDeclaration | undefined;
|
|
@@ -1435,9 +1435,6 @@ export const findSwiftLiskovSubstitutionMatch = (
|
|
|
1435
1435
|
}
|
|
1436
1436
|
|
|
1437
1437
|
const typeDeclarations = parseSwiftTypeDeclarations(source);
|
|
1438
|
-
if (typeDeclarations.length < 2) {
|
|
1439
|
-
return undefined;
|
|
1440
|
-
}
|
|
1441
1438
|
|
|
1442
1439
|
const sourceLines = source.split(/\r?\n/);
|
|
1443
1440
|
|
|
@@ -1450,9 +1447,6 @@ export const findSwiftLiskovSubstitutionMatch = (
|
|
|
1450
1447
|
const conformingTypes = typeDeclarations.filter((typeDeclaration) =>
|
|
1451
1448
|
typeDeclaration.conformances.includes(protocolDeclaration.name)
|
|
1452
1449
|
);
|
|
1453
|
-
if (conformingTypes.length < 2) {
|
|
1454
|
-
continue;
|
|
1455
|
-
}
|
|
1456
1450
|
|
|
1457
1451
|
for (const memberName of memberNames) {
|
|
1458
1452
|
let safeType: SwiftTypeDeclaration | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pumuki",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.124",
|
|
4
4
|
"description": "Enterprise-grade AST Intelligence System with multi-platform support (iOS, Android, Backend, Frontend) and Feature-First + DDD + Clean Architecture enforcement. Includes dynamic violations API for intelligent querying.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|