@greenarmor/ges-audit-engine 0.5.2 → 0.5.3

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.
@@ -19,7 +19,8 @@ const WEAK_CRYPTO_PATTERNS = [
19
19
  ];
20
20
  const INSECURE_PASSWORD_PATTERNS = [
21
21
  { pattern: /\.compare\s*\(.*,\s*.*\)|bcrypt\.compare|argon2\.verify/gi, check: false, desc: "Secure password comparison" },
22
- { pattern: /password\s*===?\s*|password\s*!==?\s*|\.equals\s*\(\s*password/gi, check: true, desc: "Plaintext password comparison (use Argon2id/bcrypt)" },
22
+ { pattern: /(?:stored|saved|hashed|db|database)\s*\.?\s*(?:password|pw)\s*===?\s*(?:req|input|user|plain|raw)/gi, check: true, desc: "Plaintext password comparison (use Argon2id/bcrypt)" },
23
+ { pattern: /(?:password|pw)\s*===?\s*['"][^'"]{2,}['"]/gi, check: true, desc: "Hardcoded password comparison (use Argon2id/bcrypt)" },
23
24
  ];
24
25
  const SCAN_EXTENSIONS = new Set([".ts", ".tsx", ".js", ".jsx", ".py", ".rb", ".go", ".java", ".php", ".cs"]);
25
26
  export class CryptoScanner {
@@ -16,9 +16,14 @@ const ORM_ENTITY_PATTERNS = {
16
16
  ".java": /@Entity\s*(?:public\s+)?class/i,
17
17
  ".php": /class\s+\w+\s+extends\s+(?:Model|Eloquent|Doctrine)/i,
18
18
  };
19
+ const MIGRATION_DIR_PATTERN = /[\/\\]migrations?[\/\\]/i;
19
20
  function isDatabaseSchemaFile(filePath, content) {
20
21
  const ext = filePath.substring(filePath.lastIndexOf("."));
21
22
  const basename = filePath.substring(filePath.lastIndexOf("/") + 1);
23
+ if (ext === ".prisma")
24
+ return true;
25
+ if (MIGRATION_DIR_PATTERN.test(filePath))
26
+ return false;
22
27
  if (DB_SCHEMA_EXTENSIONS.has(ext))
23
28
  return true;
24
29
  for (const pattern of DB_SCHEMA_FILENAMES) {
@@ -46,9 +51,14 @@ export class DatabaseScanner {
46
51
  for (const [filePath, content] of ctx.fileContents) {
47
52
  if (!isDatabaseSchemaFile(filePath, content))
48
53
  continue;
49
- const hasTimestamps = /\b(?:timestamps|created_at|createdAt|createdDate|date_created|timecreated|createdTime)\s*[:\(]/i.test(content);
50
- const hasSoftDelete = /\b(?:deleted_at|deletedAt|softDelete|paranoid|is_deleted|isDeleted|deleted|active)\s*[:\(]/i.test(content);
51
- const hasUserAudit = /\b(?:created_by|createdBy|updated_by|updatedBy|owner_id|author_id)\s*[:\(]/i.test(content);
54
+ const isPrisma = filePath.endsWith(".prisma");
55
+ const hasTimestamps = isPrisma
56
+ ? /\b(?:createdAt|created_at)\b.*(?:DateTime|timestamp)/i.test(content)
57
+ : /\b(?:timestamps|created_at|createdAt|createdDate|date_created|timecreated|createdTime)\s*[:\(]/i.test(content);
58
+ const hasSoftDelete = /\b(?:deleted_at|deletedAt|softDelete|paranoid|is_deleted|isDeleted|deleted|active)\s*[:\(]/i.test(content)
59
+ || (isPrisma && /\b(?:deletedAt|deleted_at)\s+DateTime/i.test(content));
60
+ const hasUserAudit = /\b(?:created_by|createdBy|updated_by|updatedBy|owner_id|author_id)\s*[:\(]/i.test(content)
61
+ || (isPrisma && /\b(?:createdBy|updatedBy|ownerId|authorId)\s+String/i.test(content));
52
62
  const hasSchemaDef = /\b(?:model|schema|entity|table|struct|class)\b.*\{/i.test(content) ||
53
63
  /\bCREATE\s+TABLE\b/i.test(content) ||
54
64
  /@(?:Entity|Table|Schema)\b/.test(content);
@@ -20,11 +20,15 @@ const IGNORE_DIRS = new Set([
20
20
  const IGNORE_FILES = new Set([
21
21
  ".gitignore", "package-lock.json", "pnpm-lock.yaml", "yarn.lock",
22
22
  ]);
23
+ const DOTENV_FILES = /^\.env(?:\.\w+)?$/;
23
24
  function shouldScanFile(filePath) {
24
25
  const parts = filePath.split("/");
25
26
  if (parts.some(p => IGNORE_DIRS.has(p)))
26
27
  return false;
27
- if (IGNORE_FILES.has(parts[parts.length - 1] || ""))
28
+ const basename = parts[parts.length - 1] || "";
29
+ if (IGNORE_FILES.has(basename))
30
+ return false;
31
+ if (DOTENV_FILES.test(basename))
28
32
  return false;
29
33
  return true;
30
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greenarmor/ges-audit-engine",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "type": "module",
5
5
  "description": "GESF Audit Engine - Audit trails and compliance evaluation",
6
6
  "main": "./dist/index.js",
@@ -12,7 +12,7 @@
12
12
  }
13
13
  },
14
14
  "dependencies": {
15
- "@greenarmor/ges-core": "0.5.2"
15
+ "@greenarmor/ges-core": "0.5.3"
16
16
  },
17
17
  "devDependencies": {
18
18
  "typescript": "^6.0.0",