@activemind/scd 1.4.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.
Files changed (79) hide show
  1. package/LICENSE.md +35 -0
  2. package/README.md +417 -0
  3. package/bin/scd.js +140 -0
  4. package/lib/audit-report.js +93 -0
  5. package/lib/audit-sync.js +172 -0
  6. package/lib/audit.js +356 -0
  7. package/lib/cli-helpers.js +108 -0
  8. package/lib/commands/accept.js +28 -0
  9. package/lib/commands/audit.js +17 -0
  10. package/lib/commands/configure.js +200 -0
  11. package/lib/commands/doctor.js +14 -0
  12. package/lib/commands/exceptions.js +19 -0
  13. package/lib/commands/export-findings.js +46 -0
  14. package/lib/commands/findings.js +306 -0
  15. package/lib/commands/ignore.js +28 -0
  16. package/lib/commands/init.js +16 -0
  17. package/lib/commands/insights.js +24 -0
  18. package/lib/commands/install.js +15 -0
  19. package/lib/commands/list.js +109 -0
  20. package/lib/commands/remove.js +16 -0
  21. package/lib/commands/repo.js +862 -0
  22. package/lib/commands/report.js +234 -0
  23. package/lib/commands/resolve.js +25 -0
  24. package/lib/commands/rules.js +185 -0
  25. package/lib/commands/scan.js +519 -0
  26. package/lib/commands/scope.js +341 -0
  27. package/lib/commands/sync.js +40 -0
  28. package/lib/commands/uninstall.js +15 -0
  29. package/lib/commands/version.js +33 -0
  30. package/lib/comment-map.js +388 -0
  31. package/lib/config.js +325 -0
  32. package/lib/context-modifiers.js +211 -0
  33. package/lib/deep-analyzer.js +225 -0
  34. package/lib/doctor.js +236 -0
  35. package/lib/exception-manager.js +675 -0
  36. package/lib/export-findings.js +376 -0
  37. package/lib/file-context.js +380 -0
  38. package/lib/file-filter.js +204 -0
  39. package/lib/file-manifest.js +145 -0
  40. package/lib/git-utils.js +102 -0
  41. package/lib/global-config.js +239 -0
  42. package/lib/hooks-manager.js +130 -0
  43. package/lib/init-repo.js +147 -0
  44. package/lib/insights-analyzer.js +416 -0
  45. package/lib/insights-output.js +160 -0
  46. package/lib/installer.js +128 -0
  47. package/lib/output-constants.js +32 -0
  48. package/lib/output-terminal.js +407 -0
  49. package/lib/push-queue.js +322 -0
  50. package/lib/remove-repo.js +108 -0
  51. package/lib/repo-context.js +187 -0
  52. package/lib/report-html.js +1154 -0
  53. package/lib/report-index.js +157 -0
  54. package/lib/report-json.js +136 -0
  55. package/lib/report-markdown.js +250 -0
  56. package/lib/resolve-manager.js +148 -0
  57. package/lib/rule-registry.js +205 -0
  58. package/lib/scan-cache.js +171 -0
  59. package/lib/scan-context.js +312 -0
  60. package/lib/scan-schema.js +67 -0
  61. package/lib/scanner-full.js +681 -0
  62. package/lib/scanner-manual.js +348 -0
  63. package/lib/scanner-secrets.js +83 -0
  64. package/lib/scope.js +331 -0
  65. package/lib/store-verify.js +395 -0
  66. package/lib/store.js +310 -0
  67. package/lib/taint-register.js +196 -0
  68. package/lib/version-check.js +46 -0
  69. package/package.json +37 -0
  70. package/rules/rule-loader.js +324 -0
  71. package/rules/rules-aspx-cs.json +399 -0
  72. package/rules/rules-aspx.json +222 -0
  73. package/rules/rules-infra-leakage.json +434 -0
  74. package/rules/rules-js.json +664 -0
  75. package/rules/rules-php.json +521 -0
  76. package/rules/rules-python.json +466 -0
  77. package/rules/rules-secrets.json +99 -0
  78. package/rules/rules-sensitive-files.json +475 -0
  79. package/rules/rules-ts.json +76 -0
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * scan-schema.js
5
+ * Canonical shape of a scan object persisted by scan-cache.js.
6
+ *
7
+ * Written by:
8
+ * scan-cache.js → saveCache()
9
+ *
10
+ * Read by:
11
+ * bin/scd.js → scd findings, scd report, scd repo scans, scd export-findings
12
+ * lib/exception-manager.js → addExceptionById() (reads findings[].findingId, codeHash)
13
+ * lib/report-html.js → generateReport() (reads: findings, target, scanDate, totalFiles, skipped, repoRoot)
14
+ * lib/report-json.js → generateReport() (reads: findings, target, scanDate, totalFiles)
15
+ * lib/report-markdown.js → (reads: findings, target, scanDate, totalFiles, skipped)
16
+ * lib/export-findings.js → exportFindings() (reads: findings, scanId, repoRoot)
17
+ * lib/audit.js → logScan() (receives scan data as arguments, not from cache directly)
18
+ *
19
+ * Field inventory:
20
+ *
21
+ * scanId {string} "s-{8hex}" — random, unique per scan run
22
+ * scanDate {string} ISO 8601 — timestamp of scan
23
+ * target {string} CLI target argument, e.g. "." or "src/app.js"
24
+ * totalFiles {number} Number of files scanned
25
+ * skipped {Array} Files skipped: [{ filePath, reason, error? }]
26
+ * findings {Array} Finding objects from scanner-full.js / scanner-secrets.js
27
+ * deepResults {Array|null} Deep analysis results, or null if --deep not used
28
+ * hasDeep {boolean} True if deepResults is non-empty
29
+ * repoRoot {string} Absolute path to the repo root at scan time
30
+ * scanMode {string} "full" | "fast" — from config.scan_mode
31
+ * exclusions {null} Reserved for future .scdignore + rule_excludes (Phase 4)
32
+ *
33
+ * Note: repoRoot and scanMode were previously only sent to logScan(), not persisted
34
+ * in the scan file. They are now included in the payload so all consumers have
35
+ * full context without needing to re-resolve the repo root from disk.
36
+ */
37
+
38
+ const REQUIRED_FIELDS = [
39
+ 'scanId',
40
+ 'scanDate',
41
+ 'target',
42
+ 'totalFiles',
43
+ 'skipped',
44
+ 'findings',
45
+ 'repoRoot',
46
+ 'scanMode',
47
+ ];
48
+
49
+ /**
50
+ * Validate a scan object and warn on missing required fields.
51
+ * Never throws — always returns the object as-is.
52
+ *
53
+ * @param {object} obj The scan object to validate
54
+ * @param {string} context Optional label for the warning (e.g. 'saveCache')
55
+ * @returns {object} The same object, unmodified
56
+ */
57
+ function validateScan(obj, context) {
58
+ for (const field of REQUIRED_FIELDS) {
59
+ if (obj[field] === undefined) {
60
+ const label = context ? ' (' + context + ')' : '';
61
+ console.warn('[scd] scan object missing field: ' + field + label);
62
+ }
63
+ }
64
+ return obj;
65
+ }
66
+
67
+ module.exports = { validateScan, REQUIRED_FIELDS };