@dailephd/my-dev-kit-lab 0.4.5 → 0.4.6

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 (231) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +37 -3
  3. package/dist/scripts/cli.js +9 -0
  4. package/dist/src/audits/core/typescriptJavaScriptAnalyzer.js +30 -12
  5. package/dist/src/cli/help.js +300 -0
  6. package/dist/src/cli/index.js +2 -0
  7. package/dist/src/cli/runLabCli.js +229 -0
  8. package/dist/src/commands/runAuditCommand.js +132 -0
  9. package/dist/src/commands/runControlledExperimentCommand.js +7 -3
  10. package/dist/{scripts/experiments/describeExperiment.js → src/commands/runExperimentDescribeCommand.js} +14 -10
  11. package/dist/{scripts/experiments/listExperiments.js → src/commands/runExperimentListCommand.js} +3 -6
  12. package/dist/{scripts/experiments/runExperiment.js → src/commands/runExperimentRunCommand.js} +80 -22
  13. package/dist/src/commands/runFinalDemoCommand.js +2 -3
  14. package/dist/src/commands/runSecurityValidationCommand.js +271 -0
  15. package/dist/src/runtime/index.js +3 -0
  16. package/dist/src/runtime/labExecutionContext.js +22 -0
  17. package/dist/src/runtime/packageResource.js +22 -0
  18. package/dist/src/runtime/packageRoot.js +37 -0
  19. package/dist/src/securityValidation/packageChecks/requiredPackageContents.js +14 -1
  20. package/package.json +7 -7
  21. package/dist/scripts/audits/runAudit.js +0 -135
  22. package/dist/scripts/build-gallery.js +0 -3
  23. package/dist/scripts/capture-demo-report.js +0 -3
  24. package/dist/scripts/evaluate-token-savings.js +0 -2
  25. package/dist/scripts/generate-experiment-plots.js +0 -3
  26. package/dist/scripts/generate-prompt-variants.js +0 -2
  27. package/dist/scripts/render-experiment-report.js +0 -2
  28. package/dist/scripts/report-context-integrity-smoke.js +0 -70
  29. package/dist/scripts/run-agent-prompt.js +0 -2
  30. package/dist/scripts/run-controlled-experiment.js +0 -2
  31. package/dist/scripts/run-lab-demo.js +0 -5
  32. package/dist/scripts/run-visualization-demos.js +0 -3
  33. package/dist/scripts/security/resolveToolRoot.js +0 -16
  34. package/dist/scripts/security/runCodeql.js +0 -58
  35. package/dist/scripts/security/runDependencyChecks.js +0 -58
  36. package/dist/scripts/security/runFuzzSmoke.js +0 -29
  37. package/dist/scripts/security/runPackageChecks.js +0 -57
  38. package/dist/scripts/security/runSemgrep.js +0 -64
  39. package/dist/scripts/security/validate.js +0 -266
  40. package/dist/scripts/verify-benchmarks.js +0 -202
  41. package/examples/demo-report-input.json +0 -78
  42. package/examples/lab-demo-cases.json +0 -35
  43. package/examples/real-agent-campaign-cases.json +0 -118
  44. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-a/src/debug/res/xml/ambiguous_backup_rules.xml +0 -4
  45. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-a/src/main/res/xml/ambiguous_backup_rules.xml +0 -4
  46. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-a/src/main/res/xml/backup_rules.xml +0 -5
  47. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-a/src/main/res/xml/broad_backup_rules.xml +0 -4
  48. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-a/src/main/res/xml/data_extraction_rules.xml +0 -10
  49. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-a/src/main/res/xml/unsupported_domain_rules.xml +0 -4
  50. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-b/src/main/res/xml/malformed_backup_rules.xml +0 -4
  51. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-b/src/main/res/xml/unsupported_root.xml +0 -4
  52. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-a/src/debug/res/xml/ambiguous_config.xml +0 -4
  53. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-a/src/main/res/xml/ambiguous_config.xml +0 -4
  54. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-a/src/main/res/xml/base_cleartext_false.xml +0 -8
  55. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-a/src/main/res/xml/broad_and_duplicate_domains.xml +0 -8
  56. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-a/src/main/res/xml/empty_domain.xml +0 -6
  57. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-a/src/main/res/xml/malformed_pin.xml +0 -11
  58. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-a/src/main/res/xml/network_security_config.xml +0 -26
  59. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-b/src/main/res/xml/malformed_network_security_config.xml +0 -6
  60. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-b/src/main/res/xml/unsupported_root.xml +0 -4
  61. package/tests/fixtures/android/advanced-security-fixtures/release-configuration/groovy-release-debuggable-dynamic.gradle +0 -7
  62. package/tests/fixtures/android/advanced-security-fixtures/release-configuration/groovy-release-debuggable-false.gradle +0 -9
  63. package/tests/fixtures/android/advanced-security-fixtures/release-configuration/groovy-release-debuggable-true.gradle +0 -13
  64. package/tests/fixtures/android/advanced-security-fixtures/release-configuration/kotlin-release-debuggable-false.gradle.kts +0 -7
  65. package/tests/fixtures/android/advanced-security-fixtures/release-configuration/kotlin-release-debuggable-true.gradle.kts +0 -10
  66. package/tests/fixtures/android/advanced-security-fixtures/release-configuration/missing-release-build-type.gradle.kts +0 -7
  67. package/tests/fixtures/android/advanced-security-fixtures/resource-resolution/module-a/src/debug/res/xml/network_security_config.xml +0 -8
  68. package/tests/fixtures/android/advanced-security-fixtures/resource-resolution/module-a/src/main/res/xml/backup_rules.xml +0 -4
  69. package/tests/fixtures/android/advanced-security-fixtures/resource-resolution/module-a/src/main/res/xml/network_security_config.xml +0 -8
  70. package/tests/fixtures/android/advanced-security-fixtures/resource-resolution/module-b/src/main/res/xml/malformed_network_security_config.xml +0 -7
  71. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates/SampleActivity.java +0 -8
  72. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates/SampleActivity.kt +0 -9
  73. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates/build.gradle +0 -11
  74. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates/build.gradle.kts +0 -11
  75. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates/google-services.json +0 -16
  76. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates/local.properties +0 -3
  77. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates-bounds/module/binary.properties +0 -0
  78. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates-bounds/module/oversized.json +0 -1
  79. package/tests/fixtures/android/advanced-security-fixtures/signing-configuration/app/fake-release-keystore.jks +0 -1
  80. package/tests/fixtures/android/advanced-security-fixtures/signing-configuration/build/generated-fake.keystore +0 -1
  81. package/tests/fixtures/android/compose-app/app/build.gradle.kts +0 -21
  82. package/tests/fixtures/android/compose-app/app/src/main/AndroidManifest.xml +0 -22
  83. package/tests/fixtures/android/compose-app/app/src/main/java/com/example/composeapp/MainActivity.kt +0 -11
  84. package/tests/fixtures/android/compose-app/build.gradle.kts +0 -4
  85. package/tests/fixtures/android/compose-app/gradle/wrapper/gradle-wrapper.properties +0 -4
  86. package/tests/fixtures/android/compose-app/settings.gradle.kts +0 -2
  87. package/tests/fixtures/android/gradle-metadata-fixtures/catalog-only-plugin/build.gradle.kts +0 -3
  88. package/tests/fixtures/android/gradle-metadata-fixtures/catalog-only-plugin/gradle/libs.versions.toml +0 -5
  89. package/tests/fixtures/android/gradle-metadata-fixtures/comment-safety.gradle.kts +0 -21
  90. package/tests/fixtures/android/gradle-metadata-fixtures/dynamic-values.gradle.kts +0 -17
  91. package/tests/fixtures/android/gradle-metadata-fixtures/groovy-literal.gradle +0 -23
  92. package/tests/fixtures/android/gradle-metadata-fixtures/wrapper-malformed.properties +0 -4
  93. package/tests/fixtures/android/gradle-metadata-fixtures/wrapper-missing-url.properties +0 -3
  94. package/tests/fixtures/android/gradle-metadata-fixtures/wrapper-with-checksum.properties +0 -5
  95. package/tests/fixtures/android/java-app/app/build.gradle +0 -16
  96. package/tests/fixtures/android/java-app/app/src/main/AndroidManifest.xml +0 -19
  97. package/tests/fixtures/android/java-app/app/src/main/java/com/example/javaapp/MainActivity.java +0 -4
  98. package/tests/fixtures/android/java-app/build.gradle +0 -3
  99. package/tests/fixtures/android/java-app/gradle/wrapper/gradle-wrapper.properties +0 -4
  100. package/tests/fixtures/android/java-app/settings.gradle +0 -2
  101. package/tests/fixtures/android/library/build.gradle.kts +0 -3
  102. package/tests/fixtures/android/library/gradle/wrapper/gradle-wrapper.properties +0 -4
  103. package/tests/fixtures/android/library/mylibrary/build.gradle.kts +0 -13
  104. package/tests/fixtures/android/library/mylibrary/src/main/AndroidManifest.xml +0 -2
  105. package/tests/fixtures/android/library/settings.gradle.kts +0 -2
  106. package/tests/fixtures/android/manifest-audit-fixtures/incomplete-intent-filter.xml +0 -14
  107. package/tests/fixtures/android/manifest-audit-fixtures/malformed-exported.xml +0 -10
  108. package/tests/fixtures/android/manifest-audit-fixtures/malformed.xml +0 -5
  109. package/tests/fixtures/android/manifest-audit-fixtures/missing-application.xml +0 -7
  110. package/tests/fixtures/android/manifest-audit-fixtures/missing-component-name.xml +0 -11
  111. package/tests/fixtures/android/manifest-audit-fixtures/permission-coverage.xml +0 -29
  112. package/tests/fixtures/android/manifest-audit-fixtures/risky-components.xml +0 -62
  113. package/tests/fixtures/android/manifest-audit-fixtures/risky-deep-links.xml +0 -45
  114. package/tests/fixtures/android/manifest-audit-fixtures/unresolved-placeholder.xml +0 -14
  115. package/tests/fixtures/android/manifest-audit-fixtures/unusual-namespace-prefix.xml +0 -11
  116. package/tests/fixtures/android/multi-module/app/build.gradle.kts +0 -22
  117. package/tests/fixtures/android/multi-module/app/src/androidTest/java/com/example/multimodule/app/ExampleInstrumentedTest.kt +0 -3
  118. package/tests/fixtures/android/multi-module/app/src/main/AndroidManifest.xml +0 -11
  119. package/tests/fixtures/android/multi-module/app/src/test/java/com/example/multimodule/app/ExampleUnitTest.kt +0 -3
  120. package/tests/fixtures/android/multi-module/build.gradle.kts +0 -5
  121. package/tests/fixtures/android/multi-module/core/build.gradle.kts +0 -14
  122. package/tests/fixtures/android/multi-module/core/src/main/AndroidManifest.xml +0 -2
  123. package/tests/fixtures/android/multi-module/feature-login/build.gradle.kts +0 -18
  124. package/tests/fixtures/android/multi-module/feature-login/src/main/AndroidManifest.xml +0 -2
  125. package/tests/fixtures/android/multi-module/gradle/libs.versions.toml +0 -8
  126. package/tests/fixtures/android/multi-module/gradle/wrapper/gradle-wrapper.properties +0 -4
  127. package/tests/fixtures/android/multi-module/settings.gradle.kts +0 -4
  128. package/tests/fixtures/android/non-android-gradle/build.gradle.kts +0 -3
  129. package/tests/fixtures/android/non-android-gradle/core/build.gradle.kts +0 -3
  130. package/tests/fixtures/android/non-android-gradle/core/src/main/java/com/example/core/Core.java +0 -4
  131. package/tests/fixtures/android/non-android-gradle/gradle/wrapper/gradle-wrapper.properties +0 -4
  132. package/tests/fixtures/android/non-android-gradle/settings.gradle.kts +0 -2
  133. package/tests/fixtures/android/partial/app/build.gradle.kts +0 -7
  134. package/tests/fixtures/android/partial/settings.gradle.kts +0 -2
  135. package/tests/fixtures/android/xml-view-app/app/build.gradle.kts +0 -17
  136. package/tests/fixtures/android/xml-view-app/app/src/main/AndroidManifest.xml +0 -31
  137. package/tests/fixtures/android/xml-view-app/app/src/main/kotlin/com/example/xmlviewapp/MainActivity.kt +0 -7
  138. package/tests/fixtures/android/xml-view-app/app/src/main/res/layout/activity_main.xml +0 -4
  139. package/tests/fixtures/android/xml-view-app/build.gradle.kts +0 -4
  140. package/tests/fixtures/android/xml-view-app/gradle/wrapper/gradle-wrapper.properties +0 -4
  141. package/tests/fixtures/android/xml-view-app/settings.gradle.kts +0 -2
  142. package/tests/fixtures/audits/mixed-language/mixed-docs-claims/README.md +0 -16
  143. package/tests/fixtures/audits/mixed-language/mixed-docs-claims/build.gradle.kts +0 -4
  144. package/tests/fixtures/audits/mixed-language/mixed-docs-claims/src/main/java/com/example/Widget.java +0 -7
  145. package/tests/fixtures/audits/mixed-language/mixed-docs-claims/src/main/kotlin/com/example/Gadget.kt +0 -7
  146. package/tests/fixtures/audits/mixed-language/mixed-generated-vendor/README.md +0 -10
  147. package/tests/fixtures/audits/mixed-language/mixed-generated-vendor/build/Main.class +0 -1
  148. package/tests/fixtures/audits/mixed-language/mixed-generated-vendor/dist/index.js +0 -1
  149. package/tests/fixtures/audits/mixed-language/mixed-generated-vendor/generated/schema.ts +0 -1
  150. package/tests/fixtures/audits/mixed-language/mixed-generated-vendor/src/index.ts +0 -3
  151. package/tests/fixtures/audits/mixed-language/mixed-generated-vendor/vendor/lib.py +0 -2
  152. package/tests/fixtures/audits/mixed-language/mixed-java-kotlin/README.md +0 -10
  153. package/tests/fixtures/audits/mixed-language/mixed-java-kotlin/build.gradle.kts +0 -8
  154. package/tests/fixtures/audits/mixed-language/mixed-java-kotlin/settings.gradle.kts +0 -1
  155. package/tests/fixtures/audits/mixed-language/mixed-java-kotlin/src/main/java/com/example/FooService.java +0 -7
  156. package/tests/fixtures/audits/mixed-language/mixed-java-kotlin/src/main/kotlin/com/example/BarService.kt +0 -7
  157. package/tests/fixtures/audits/mixed-language/mixed-java-kotlin/src/test/java/com/example/FooServiceTest.java +0 -8
  158. package/tests/fixtures/audits/mixed-language/mixed-java-kotlin/src/test/kotlin/com/example/BarServiceTest.kt +0 -8
  159. package/tests/fixtures/audits/mixed-language/mixed-python-ts/README.md +0 -8
  160. package/tests/fixtures/audits/mixed-language/mixed-python-ts/src/app.py +0 -7
  161. package/tests/fixtures/audits/mixed-language/mixed-python-ts/src/index.ts +0 -3
  162. package/tests/fixtures/audits/mixed-language/mixed-python-ts/tests/test_app.py +0 -5
  163. package/tests/fixtures/audits/mixed-language/mixed-ts-js/README.md +0 -7
  164. package/tests/fixtures/audits/mixed-language/mixed-ts-js/src/helper.js +0 -5
  165. package/tests/fixtures/audits/mixed-language/mixed-ts-js/src/index.ts +0 -3
  166. package/tests/fixtures/audits/mixed-language/mixed-ts-js/tests/index.sample.ts +0 -5
  167. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/README.md +0 -10
  168. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/build.gradle.kts +0 -4
  169. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/pytests/test_app.py +0 -5
  170. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/src/app.py +0 -2
  171. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/src/helper.js +0 -5
  172. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/src/index.ts +0 -3
  173. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/src/main/java/com/example/Multiplier.java +0 -7
  174. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/src/main/kotlin/com/example/Divider.kt +0 -7
  175. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/corrected-replay/derived/run-integrity-evidence.json +0 -99
  176. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/corrected-replay/producer/implementation-audit.json +0 -1585
  177. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/corrected-replay/producer/implementation-capsule.json +0 -11455
  178. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/00-request.txt +0 -1
  179. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/architecture-context-packet.txt +0 -82
  180. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/behavior-model.txt +0 -104
  181. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/final-report.txt +0 -41
  182. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/implementation-context-packet.txt +0 -114
  183. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/implementation-report.txt +0 -92
  184. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/judge-report.txt +0 -34
  185. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/pseudocode-packet.txt +0 -244
  186. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/request-brief.txt +0 -40
  187. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/test-context-packet.txt +0 -93
  188. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/test-implementation-report.txt +0 -69
  189. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/test-strategy-packet.txt +0 -354
  190. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/verification-report.txt +0 -85
  191. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/derived/run-integrity-evidence.json +0 -98
  192. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/architecture-audit.json +0 -1169
  193. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/architecture-request.json +0 -29
  194. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/implementation-audit.json +0 -1494
  195. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/implementation-capsule.json +0 -11364
  196. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/implementation-request.json +0 -33
  197. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/test-request.json +0 -74
  198. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/reports/architecture-context-retrieval-report.txt +0 -58
  199. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/reports/implementation-context-retrieval-report.txt +0 -75
  200. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/reports/test-context-retrieval-report.txt +0 -84
  201. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/run.json +0 -62
  202. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/tool-versions/my-dev-kit-version.txt +0 -1
  203. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/tool-versions/orchestrator-version.txt +0 -1
  204. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/manifests/corrected-replay-manifest.json +0 -19
  205. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/manifests/failed-run-manifest.json +0 -56
  206. package/tests/fixtures/fake-adversarial-cli.js +0 -152
  207. package/tests/fixtures/fake-my-dev-kit-cli.js +0 -83
  208. package/tests/fixtures/full-workflow-library/complete-v1.0.0.json +0 -24
  209. package/tests/fixtures/full-workflow-library/future-minor-v1.1.0-additive.json +0 -25
  210. package/tests/fixtures/stage-context-expectations/complete-v1.0.0.json +0 -230
  211. package/tests/fixtures/stage-context-expectations/future-minor-v1.1.0-additive.json +0 -232
  212. package/tests/fixtures/stage-context-expectations/invalid/malformed-json.txt +0 -1
  213. package/tests/fixtures/stage-context-expectations/invalid/non-object-root.json +0 -1
  214. package/tests/fixtures/stage-context-expectations/minimal-v1.0.0.json +0 -18
  215. package/tests/fixtures/upstream-artifacts/invalid/malformed-json.txt +0 -1
  216. package/tests/fixtures/upstream-artifacts/invalid/non-object-root.json +0 -1
  217. package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.2/context-capsule/complete-v1.0.0.json +0 -504
  218. package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.2/context-capsule/future-minor-v1.1.0-additive.json +0 -955
  219. package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.2/retrieval-audit-record/complete-v1.0.0.json +0 -190
  220. package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.2/retrieval-audit-record/future-minor-v1.1.0-additive.json +0 -327
  221. package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.4/PROVENANCE.txt +0 -18
  222. package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.4/context-capsule/complete-v1.0.0.json +0 -556
  223. package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.4/retrieval-audit-record/complete-v1.0.0.json +0 -238
  224. package/tests/fixtures/upstream-artifacts/my-dev-kit-1.10.2-identity/PROVENANCE.txt +0 -13
  225. package/tests/fixtures/upstream-artifacts/my-dev-kit-1.10.2-identity/context-capsule.json +0 -7874
  226. package/tests/fixtures/upstream-artifacts/my-dev-kit-1.10.2-identity/retrieval-audit-record.json +0 -1076
  227. package/tests/fixtures/upstream-artifacts/my-dev-kit-orchestrator/1.2.1/workflow-instruction-packet/complete-v1.0.0.json +0 -160
  228. package/tests/fixtures/upstream-artifacts/my-dev-kit-orchestrator/1.2.1/workflow-instruction-packet/future-minor-v1.1.0-additive.json +0 -186
  229. package/tests/fixtures/upstream-artifacts/my-dev-kit-orchestrator/1.2.3/run-integrity/PROVENANCE.txt +0 -31
  230. package/tests/fixtures/upstream-artifacts/my-dev-kit-orchestrator/1.2.3/run-integrity/ready-pass-final-pass.json +0 -132
  231. package/tests/fixtures/upstream-artifacts/my-dev-kit-orchestrator/1.2.3/run-integrity/refresh-required-need-context.json +0 -146
@@ -1,70 +0,0 @@
1
- // v0.4.5 context-integrity evaluation: report smoke script. Loads the frozen failed-run and
2
- // corrected-replay fixtures, evaluates them through the existing producer-readiness bridge,
3
- // and writes JSON/text/HTML reports for manual inspection. Not part of any release-readiness
4
- // gate; a developer convenience for inspecting ContextIntegrityReportV1 output.
5
- import { mkdirSync, writeFileSync } from "node:fs";
6
- import { loadContextIntegrityFixture } from "../src/evaluation/ecosystemFixtures/loadContextIntegrityFixture.js";
7
- import { evaluateProducerReadinessBridge } from "../src/evaluation/stageContextMetrics/evaluateProducerReadinessBridge.js";
8
- import { calculateStageContextDeterminism } from "../src/evaluation/stageContextDeterminism/calculateStageContextDeterminism.js";
9
- import { buildContextIntegrityReport } from "../src/report/experiments/buildContextIntegrityReport.js";
10
- import { renderContextIntegrityJsonReport } from "../src/report/experiments/renderContextIntegrityJsonReport.js";
11
- import { renderContextIntegrityText } from "../src/report/experiments/renderContextIntegrityText.js";
12
- import { renderContextIntegrityHtml } from "../src/report/experiments/renderContextIntegrityHtml.js";
13
- const CASES = [
14
- {
15
- kind: "failed-run",
16
- root: "tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run",
17
- manifest: "tests/fixtures/ecosystem/context-integrity/v0.4.5/manifests/failed-run-manifest.json"
18
- },
19
- {
20
- kind: "corrected-replay",
21
- root: "tests/fixtures/ecosystem/context-integrity/v0.4.5/corrected-replay",
22
- manifest: "tests/fixtures/ecosystem/context-integrity/v0.4.5/manifests/corrected-replay-manifest.json"
23
- }
24
- ];
25
- async function main() {
26
- const outDir = "lab-output/context-integrity-report-smoke";
27
- mkdirSync(outDir, { recursive: true });
28
- for (const c of CASES) {
29
- const fixture = await loadContextIntegrityFixture(c.root, c.manifest);
30
- if (!fixture.ok) {
31
- console.error(`Fixture load failed for ${c.kind}:`, fixture.issues);
32
- process.exitCode = 1;
33
- continue;
34
- }
35
- const bridgeResult = evaluateProducerReadinessBridge({
36
- implementation: { role: "implementation", contextCapsule: fixture.implementationCapsule, retrievalAuditRecord: fixture.implementationAudit },
37
- readiness: fixture.runIntegrityEvidence?.gate.implementationContext,
38
- runIntegrityEvidence: fixture.runIntegrityEvidence,
39
- expectations: {
40
- schemaVersion: "1.0.0",
41
- caseId: "CASE-SMOKE",
42
- title: "smoke",
43
- description: "smoke",
44
- expectedEvidence: [],
45
- expectedStates: {},
46
- warnings: [],
47
- producerReadinessExpectations: {}
48
- }
49
- });
50
- const determinism = calculateStageContextDeterminism([
51
- { runNumber: 1, value: bridgeResult },
52
- { runNumber: 2, value: bridgeResult }
53
- ]);
54
- const report = buildContextIntegrityReport({
55
- fixtureKind: c.kind,
56
- manifest: fixture.manifest,
57
- hashVerification: fixture.hashVerification,
58
- capsule: fixture.implementationCapsule,
59
- audit: fixture.implementationAudit,
60
- bridgeResult,
61
- determinism,
62
- fixtureSelfImmutable: true
63
- });
64
- writeFileSync(`${outDir}/${c.kind}.report.json`, renderContextIntegrityJsonReport(report), "utf8");
65
- writeFileSync(`${outDir}/${c.kind}.report.txt`, renderContextIntegrityText(report), "utf8");
66
- writeFileSync(`${outDir}/${c.kind}.report.html`, renderContextIntegrityHtml(report), "utf8");
67
- console.log(`Wrote ${c.kind} reports. endToEnd=${report.endToEnd?.category}`);
68
- }
69
- }
70
- main();
@@ -1,2 +0,0 @@
1
- import { runAgentPromptCommand } from "../src/commands/runAgentPromptCommand.js";
2
- process.exitCode = await runAgentPromptCommand(process.argv.slice(2));
@@ -1,2 +0,0 @@
1
- import { runControlledExperimentCommand } from "../src/commands/runControlledExperimentCommand.js";
2
- process.exitCode = await runControlledExperimentCommand(process.argv.slice(2));
@@ -1,5 +0,0 @@
1
- import { runLabDemoCommand } from "../src/commands/runLabDemo.js";
2
- const exitCode = await runLabDemoCommand(process.argv.slice(2));
3
- if (exitCode !== 0) {
4
- process.exitCode = exitCode;
5
- }
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import { runVisualizationDemosCommand } from "../src/commands/runVisualizationDemosCommand.js";
3
- process.exitCode = await runVisualizationDemosCommand(process.argv.slice(2));
@@ -1,16 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- export function resolveToolRoot(moduleUrl) {
5
- let current = path.dirname(fileURLToPath(moduleUrl));
6
- while (true) {
7
- if (fs.existsSync(path.join(current, "package.json"))) {
8
- return current;
9
- }
10
- const parent = path.dirname(current);
11
- if (parent === current) {
12
- return process.cwd();
13
- }
14
- current = parent;
15
- }
16
- }
@@ -1,58 +0,0 @@
1
- #!/usr/bin/env node
2
- import { runCodeqlCheck } from "../../src/securityValidation/staticScans/codeql.js";
3
- import { resolveValidationTarget } from "../../src/securityValidation/validate/resolveTarget.js";
4
- import { resolveToolRoot } from "./resolveToolRoot.js";
5
- const rawArgs = process.argv.slice(2);
6
- const args = parseArgs(rawArgs);
7
- const toolRoot = resolveToolRoot(import.meta.url);
8
- let targetRoot;
9
- try {
10
- const target = resolveValidationTarget(args.target, toolRoot);
11
- targetRoot = target.targetRoot;
12
- if (!target.isSelf) {
13
- console.log(`Target: ${targetRoot}`);
14
- }
15
- }
16
- catch (err) {
17
- console.error(`ERROR: ${err instanceof Error ? err.message : String(err)}`);
18
- process.exitCode = 1;
19
- process.exit(1);
20
- }
21
- console.log("Running CodeQL static analysis check...");
22
- const result = await runCodeqlCheck({
23
- cwd: toolRoot,
24
- targetRoot,
25
- timeoutMs: 30_000,
26
- });
27
- const label = result.status === "skipped"
28
- ? `SKIPPED — ${result.skippedReason ?? "tool unavailable"}`
29
- : result.status.toUpperCase();
30
- console.log(`Status: ${label}`);
31
- if (result.findings.length > 0) {
32
- console.log("\nFindings:");
33
- for (const f of result.findings) {
34
- console.log(` [${f.severity.toUpperCase()}] ${f.title}`);
35
- if (f.description)
36
- console.log(` ${f.description.slice(0, 120)}`);
37
- }
38
- }
39
- console.log(`\nDuration: ${result.durationMs}ms`);
40
- if (result.status === "skipped") {
41
- console.log("\nCodeQL is optional. Absence does not block release.");
42
- process.exitCode = 0;
43
- }
44
- else if (result.status === "failed") {
45
- process.exitCode = 1;
46
- }
47
- else {
48
- process.exitCode = 0;
49
- }
50
- function parseArgs(argv) {
51
- const result = {};
52
- for (let i = 0; i < argv.length; i++) {
53
- if ((argv[i] === "--target" || argv[i] === "-t") && i + 1 < argv.length) {
54
- result.target = argv[++i];
55
- }
56
- }
57
- return result;
58
- }
@@ -1,58 +0,0 @@
1
- #!/usr/bin/env node
2
- import path from "node:path";
3
- import { runDependencyChecks } from "../../src/securityValidation/index.js";
4
- import { DEFAULT_SECURITY_CONFIG } from "../../src/securityValidation/index.js";
5
- import { resolveValidationTarget } from "../../src/securityValidation/validate/resolveTarget.js";
6
- import { resolveToolRoot } from "./resolveToolRoot.js";
7
- const rawArgs = process.argv.slice(2);
8
- const args = parseArgs(rawArgs);
9
- const toolRoot = resolveToolRoot(import.meta.url);
10
- let targetRoot;
11
- try {
12
- const target = resolveValidationTarget(args.target, toolRoot);
13
- targetRoot = target.targetRoot;
14
- if (!target.isSelf) {
15
- console.log(`Target: ${targetRoot}`);
16
- }
17
- }
18
- catch (err) {
19
- console.error(`ERROR: ${err instanceof Error ? err.message : String(err)}`);
20
- process.exitCode = 1;
21
- process.exit(1);
22
- }
23
- const config = {
24
- ...DEFAULT_SECURITY_CONFIG,
25
- reportDir: path.join(toolRoot, DEFAULT_SECURITY_CONFIG.reportDir),
26
- rawOutputDir: path.join(toolRoot, DEFAULT_SECURITY_CONFIG.rawOutputDir),
27
- };
28
- console.log("Running dependency checks...");
29
- console.log(`Report directory: ${config.reportDir}`);
30
- const output = await runDependencyChecks({ cwd: targetRoot, config });
31
- const passed = output.checks.filter((c) => c.status === "passed").length;
32
- const failed = output.checks.filter((c) => c.status === "failed").length;
33
- const warned = output.checks.filter((c) => c.status === "warning").length;
34
- const skipped = output.checks.filter((c) => c.status === "skipped").length;
35
- console.log(`\nDependency checks complete:`);
36
- console.log(` Passed: ${passed}`);
37
- console.log(` Warned: ${warned}`);
38
- console.log(` Failed: ${failed}`);
39
- console.log(` Skipped: ${skipped}`);
40
- console.log(` Findings: ${output.findings.length}`);
41
- if (output.findings.length > 0) {
42
- console.log("\nFindings:");
43
- for (const f of output.findings) {
44
- console.log(` [${f.severity.toUpperCase()}] ${f.title}`);
45
- }
46
- }
47
- console.log(`\nResults written to ${config.reportDir}`);
48
- const hasBlocker = output.findings.some((f) => f.severity === "blocker");
49
- process.exitCode = hasBlocker ? 1 : 0;
50
- function parseArgs(argv) {
51
- const result = {};
52
- for (let i = 0; i < argv.length; i++) {
53
- if ((argv[i] === "--target" || argv[i] === "-t") && i + 1 < argv.length) {
54
- result.target = argv[++i];
55
- }
56
- }
57
- return result;
58
- }
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env node
2
- import { runAllFuzzTargets } from "../../src/securityValidation/fuzz/fuzzHarness.js";
3
- import { ALL_FUZZ_TARGETS } from "../../src/securityValidation/fuzz/fuzzTargets.js";
4
- const SEED = parseInt(process.env["FUZZ_SEED"] ?? "0xDEADBEEF", 16);
5
- const ITERATIONS = parseInt(process.env["FUZZ_ITERATIONS"] ?? "50", 10);
6
- console.log(`Running fuzz smoke tests...`);
7
- console.log(` Targets : ${ALL_FUZZ_TARGETS.length}`);
8
- console.log(` Seed : 0x${SEED.toString(16).toUpperCase()}`);
9
- console.log(` Iterations: ${ITERATIONS} per target`);
10
- const result = await runAllFuzzTargets(ALL_FUZZ_TARGETS, {
11
- seed: SEED,
12
- iterations: ITERATIONS,
13
- });
14
- console.log(`\nStatus : ${result.status.toUpperCase()}`);
15
- console.log(`Duration: ${result.durationMs}ms`);
16
- console.log(`Crashes : ${result.findings.length}`);
17
- if (result.findings.length > 0) {
18
- console.log("\nCrash findings:");
19
- for (const f of result.findings) {
20
- console.log(` [${f.severity.toUpperCase()}] ${f.title}`);
21
- if (f.evidence)
22
- console.log(` Evidence: ${f.evidence.slice(0, 160)}`);
23
- }
24
- process.exitCode = 1;
25
- }
26
- else {
27
- console.log("\nAll fuzz targets completed without crashes.");
28
- process.exitCode = 0;
29
- }
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env node
2
- import path from "node:path";
3
- import { runPackageChecks } from "../../src/securityValidation/index.js";
4
- import { DEFAULT_SECURITY_CONFIG } from "../../src/securityValidation/index.js";
5
- import { resolveValidationTarget } from "../../src/securityValidation/validate/resolveTarget.js";
6
- import { resolveToolRoot } from "./resolveToolRoot.js";
7
- const rawArgs = process.argv.slice(2);
8
- const args = parseArgs(rawArgs);
9
- const toolRoot = resolveToolRoot(import.meta.url);
10
- let targetRoot;
11
- try {
12
- const target = resolveValidationTarget(args.target, toolRoot);
13
- targetRoot = target.targetRoot;
14
- if (!target.isSelf) {
15
- console.log(`Target: ${targetRoot}`);
16
- }
17
- }
18
- catch (err) {
19
- console.error(`ERROR: ${err instanceof Error ? err.message : String(err)}`);
20
- process.exitCode = 1;
21
- process.exit(1);
22
- }
23
- const config = {
24
- ...DEFAULT_SECURITY_CONFIG,
25
- reportDir: path.join(toolRoot, DEFAULT_SECURITY_CONFIG.reportDir),
26
- rawOutputDir: path.join(toolRoot, DEFAULT_SECURITY_CONFIG.rawOutputDir),
27
- };
28
- console.log("Running package content checks...");
29
- console.log(`Report directory: ${config.reportDir}`);
30
- const output = await runPackageChecks({ cwd: targetRoot, config });
31
- const passed = output.checks.filter((c) => c.status === "passed").length;
32
- const failed = output.checks.filter((c) => c.status === "failed").length;
33
- const warned = output.checks.filter((c) => c.status === "warning").length;
34
- console.log(`\nPackage checks complete:`);
35
- console.log(` Passed: ${passed}`);
36
- console.log(` Warned: ${warned}`);
37
- console.log(` Failed: ${failed}`);
38
- console.log(` Findings: ${output.findings.length}`);
39
- if (output.findings.length > 0) {
40
- console.log("\nFindings:");
41
- for (const f of output.findings) {
42
- console.log(` [${f.severity.toUpperCase()}] ${f.title}`);
43
- }
44
- }
45
- console.log(`\nResults written to ${config.reportDir}`);
46
- const hasBlocker = output.findings.some((f) => f.severity === "blocker");
47
- const hasMajor = output.findings.some((f) => f.severity === "major");
48
- process.exitCode = hasBlocker || hasMajor ? 1 : 0;
49
- function parseArgs(argv) {
50
- const result = {};
51
- for (let i = 0; i < argv.length; i++) {
52
- if ((argv[i] === "--target" || argv[i] === "-t") && i + 1 < argv.length) {
53
- result.target = argv[++i];
54
- }
55
- }
56
- return result;
57
- }
@@ -1,64 +0,0 @@
1
- #!/usr/bin/env node
2
- import path from "node:path";
3
- import { runSemgrepCheck } from "../../src/securityValidation/staticScans/semgrep.js";
4
- import { resolveValidationTarget } from "../../src/securityValidation/validate/resolveTarget.js";
5
- import { resolveToolRoot } from "./resolveToolRoot.js";
6
- const rawArgs = process.argv.slice(2);
7
- const args = parseArgs(rawArgs);
8
- const toolRoot = resolveToolRoot(import.meta.url);
9
- let targetRoot;
10
- try {
11
- const target = resolveValidationTarget(args.target, toolRoot);
12
- targetRoot = target.targetRoot;
13
- if (!target.isSelf) {
14
- console.log(`Target: ${targetRoot}`);
15
- }
16
- }
17
- catch (err) {
18
- console.error(`ERROR: ${err instanceof Error ? err.message : String(err)}`);
19
- process.exitCode = 1;
20
- process.exit(1);
21
- }
22
- console.log("Running Semgrep static analysis check...");
23
- console.log(`Config: ${path.join(toolRoot, ".semgrep.yml")}`);
24
- const result = await runSemgrepCheck({
25
- targetRoot,
26
- toolRoot,
27
- configPath: path.join(toolRoot, ".semgrep.yml"),
28
- timeoutMs: 120_000,
29
- });
30
- const label = result.status === "skipped"
31
- ? `SKIPPED — ${result.skippedReason ?? "tool unavailable"}`
32
- : result.status.toUpperCase();
33
- console.log(`\nStatus: ${label}`);
34
- if (result.findings.length > 0) {
35
- console.log("\nFindings:");
36
- for (const f of result.findings) {
37
- console.log(` [${f.severity.toUpperCase()}] ${f.title}`);
38
- if (f.affectedFiles && f.affectedFiles.length > 0) {
39
- console.log(` Location: ${f.affectedFiles[0]}`);
40
- }
41
- if (f.description)
42
- console.log(` ${f.description.slice(0, 120)}`);
43
- }
44
- }
45
- console.log(`\nDuration: ${result.durationMs}ms`);
46
- if (result.status === "skipped") {
47
- console.log("\nSemgrep is optional. Absence does not block release.");
48
- process.exitCode = 0;
49
- }
50
- else if (result.status === "failed") {
51
- process.exitCode = 1;
52
- }
53
- else {
54
- process.exitCode = 0;
55
- }
56
- function parseArgs(argv) {
57
- const result = {};
58
- for (let i = 0; i < argv.length; i++) {
59
- if ((argv[i] === "--target" || argv[i] === "-t") && i + 1 < argv.length) {
60
- result.target = argv[++i];
61
- }
62
- }
63
- return result;
64
- }
@@ -1,266 +0,0 @@
1
- #!/usr/bin/env node
2
- import path from "node:path";
3
- import { runSecurityValidation } from "../../src/securityValidation/validate/runSecurityValidation.js";
4
- import { resolveValidationTarget, reportFilenamePrefix } from "../../src/securityValidation/validate/resolveTarget.js";
5
- import { buildSecurityReportFromSummary } from "../../src/securityValidation/report/buildSecurityReport.js";
6
- import { renderTextReport } from "../../src/securityValidation/report/renderSecurityReport.js";
7
- import { writeSecurityReportFiles } from "../../src/securityValidation/report/writeSecurityReportFiles.js";
8
- import { parseSecurityValidateArgs, normalizeSecurityValidateConfig, applyProfileDefaultChecksIfApplicable, } from "../../src/securityValidation/validate/cliOptions.js";
9
- import { resolveAttackProfile } from "../../src/securityValidation/attackScenarios/attackProfile.js";
10
- import { findingsBreachFailOnThreshold } from "../../src/securityValidation/validate/verdict.js";
11
- import { resolveToolRoot } from "./resolveToolRoot.js";
12
- import { validateAndroidTarget } from "../../src/mobile/android/validate/validateAndroidTarget.js";
13
- import { toAndroidReportModel } from "../../src/mobile/android/report/model.js";
14
- import { renderAndroidTextReport } from "../../src/mobile/android/report/renderAndroidReport.js";
15
- import { writeAndroidReportFiles } from "../../src/mobile/android/report/writeAndroidReportFiles.js";
16
- const USAGE = "Usage: npm run security:validate -- [--target <path>] [--out <dir>] [--report-prefix <name>] " +
17
- "[--checks deps,package,static,cli-adversarial,fuzz,boundary,subprocess,secrets,network] " +
18
- "[--profile node-cli-package|local-tool|npm-package|android] [--format text,json] [--fail-on blocker|high|medium|low] " +
19
- "[--android-gradle-operations wrapper-version,tasks,assemble-debug,unit-test-debug,lint-debug] " +
20
- "[--android-external-tools semgrep,osv,android-lint,dependency-check] " +
21
- "[--android-external-network deny|allow-requested]\n" +
22
- "\n" +
23
- "Android profile:\n" +
24
- " --profile android performs static, read-only Android project detection, manifest parsing,\n" +
25
- " permission/exported-component/intent-filter/deep-link audits, static Gradle metadata\n" +
26
- " extraction, and (as of v0.4.1 Batch 8) eleven internal advanced security checks (network\n" +
27
- " security config, backup/release configuration, hardcoded secrets, signing configuration,\n" +
28
- " WebView, FileProvider, sensitive storage/logging, clipboard, and Firebase/Google services).\n" +
29
- " Gradle and external tools are never executed by default.\n" +
30
- " --android-gradle-operations explicitly opts into running ONLY the listed allowlisted Gradle\n" +
31
- " operations (wrapper-version, tasks, assemble-debug, unit-test-debug, lint-debug) via the\n" +
32
- " project's own Gradle wrapper. Arbitrary Gradle tasks cannot be passed. This option is only\n" +
33
- " valid together with --profile android.\n" +
34
- " --android-external-tools explicitly opts into running ONLY the listed allowlisted optional\n" +
35
- " external security tools (semgrep, osv, android-lint, dependency-check). No arbitrary tool\n" +
36
- " names, commands, or arguments can be passed. This option is only valid together with\n" +
37
- " --profile android.\n" +
38
- " --android-external-network controls whether a requested tool may use network access.\n" +
39
- " Defaults to deny (osv is skipped unless supported offline data is available; semgrep,\n" +
40
- " android-lint, and dependency-check always run offline/no-update regardless of this flag).\n" +
41
- " allow-requested authorizes network only for an explicitly requested tool whose Batch 7\n" +
42
- " contract supports it (currently only osv). This option is only valid together with\n" +
43
- " --profile android.\n" +
44
- " Example: npm run security:validate -- --target \"<android-project-path>\" --profile android\n" +
45
- " Example: npm run security:validate -- --target \"<android-project-path>\" --profile android --android-gradle-operations wrapper-version,tasks\n" +
46
- " Example: npm run security:validate -- --target \"<android-project-path>\" --profile android --android-external-tools semgrep,android-lint\n" +
47
- " Example: npm run security:validate -- --target \"<android-project-path>\" --profile android --android-external-tools osv --android-external-network allow-requested";
48
- // Parse CLI arguments from process.argv (after the node/tsx and script path).
49
- const rawArgs = process.argv.slice(2);
50
- const toolRoot = resolveToolRoot(import.meta.url);
51
- // Help deliberately wins over every other argument. It must remain a
52
- // no-work path: no target/default resolution, option normalization, report
53
- // directory creation, validation orchestration, or subprocess execution.
54
- if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
55
- console.log(USAGE);
56
- process.exitCode = 0;
57
- process.exit(0);
58
- }
59
- let args;
60
- let config;
61
- try {
62
- args = parseSecurityValidateArgs(rawArgs);
63
- config = normalizeSecurityValidateConfig(args, toolRoot);
64
- // v0.2.2 Batch 5: --profile with no --checks uses that profile's declared
65
- // default checks. No-op unless the user passed --profile without --checks
66
- // (see applyProfileDefaultChecksIfApplicable's guard) — the true no-flag
67
- // case and any explicit --checks case are always unaffected. Skipped for
68
- // "android": that profile does not use the classic --checks pipeline.
69
- if (config.profile !== "android") {
70
- config = applyProfileDefaultChecksIfApplicable(config, resolveAttackProfile(config.profile).defaultCheckIds);
71
- }
72
- }
73
- catch (err) {
74
- const msg = err instanceof Error ? err.message : String(err);
75
- console.error(`\nERROR: ${msg}`);
76
- console.error(USAGE);
77
- process.exitCode = 2;
78
- process.exit(2);
79
- }
80
- // Resolve and validate target early so we can fail fast with a clean error.
81
- let target;
82
- try {
83
- target = resolveValidationTarget(args.target, toolRoot);
84
- }
85
- catch (err) {
86
- const msg = err instanceof Error ? err.message : String(err);
87
- console.error(`\nERROR: ${msg}`);
88
- console.error(USAGE);
89
- process.exitCode = 1;
90
- process.exit(1);
91
- }
92
- console.log("=".repeat(60));
93
- console.log("my-dev-kit-lab security:validate");
94
- console.log("=".repeat(60));
95
- console.log(`Tool root : ${toolRoot}`);
96
- if (!target.isSelf) {
97
- console.log(`Target : ${target.targetRoot}`);
98
- if (target.packageName)
99
- console.log(`Package : ${target.packageName}${target.packageVersion ? `@${target.packageVersion}` : ""}`);
100
- }
101
- else {
102
- console.log(`Mode : self-validation`);
103
- }
104
- console.log(`Profile : ${config.profile}`);
105
- // ---------------------------------------------------------------------------
106
- // v0.4.0 Batch 5 — Android profile path.
107
- //
108
- // A separate orchestrator (not the classic check-group/attack-scenario
109
- // pipeline below) because the Android check/finding/status vocabulary
110
- // established in Batches 1-4 does not fit SecurityCheckId/SecurityCheckResult.
111
- // Same command, same --profile flag, same reports/security/ output root.
112
- // ---------------------------------------------------------------------------
113
- if (config.profile === "android") {
114
- if (config.androidGradleOperationIds.length > 0) {
115
- console.log(`Gradle ops : ${config.androidGradleOperationIds.join(", ")} (explicitly requested — will execute via the target's Gradle wrapper)`);
116
- }
117
- else {
118
- console.log(`Gradle ops : (none requested — static-only validation, zero Gradle process execution)`);
119
- }
120
- // v0.4.1 Batch 8 — external tools remain explicit opt-in, mirroring Gradle
121
- // operations exactly. "allow-requested" (the CLI-facing value) maps to the
122
- // Batch 7 dispatcher's "allow-for-requested-tool" network policy value.
123
- const externalNetworkPolicy = config.androidExternalNetworkPolicy === "allow-requested" ? "allow-for-requested-tool" : "deny";
124
- if (config.androidExternalToolIds.length > 0) {
125
- console.log(`External : ${config.androidExternalToolIds.join(", ")} (explicitly requested — network policy: ${config.androidExternalNetworkPolicy})`);
126
- }
127
- else {
128
- console.log(`External : (none requested — zero external-tool process execution)`);
129
- }
130
- console.log("");
131
- const reportsDir = config.out;
132
- let result;
133
- try {
134
- result = await validateAndroidTarget({
135
- toolRoot,
136
- targetPath: args.target,
137
- requestedGradleOperationIds: config.androidGradleOperationIds,
138
- requestedExternalToolIds: config.androidExternalToolIds,
139
- externalNetworkPolicy: externalNetworkPolicy,
140
- externalToolArtifactRoot: path.join(reportsDir, "external-tools"),
141
- });
142
- }
143
- catch (err) {
144
- const msg = err instanceof Error ? err.message : String(err);
145
- console.error(`\nERROR: Android validation failed to run: ${msg}`);
146
- process.exitCode = 3;
147
- process.exit(3);
148
- }
149
- const reportModel = toAndroidReportModel(result, {
150
- profile: config.profile,
151
- requestedGradleOperations: config.androidGradleOperationIds,
152
- requestedExternalTools: config.androidExternalToolIds,
153
- externalNetworkPolicy: config.androidExternalNetworkPolicy,
154
- });
155
- const textReport = renderAndroidTextReport(reportModel);
156
- const prefix = args.reportPrefix ??
157
- reportFilenamePrefix({
158
- isSelf: result.target.local.isSelf,
159
- packageName: result.target.local.packageName,
160
- packageVersion: result.target.local.packageVersion,
161
- targetRoot: result.target.local.targetRoot,
162
- });
163
- let writtenPaths;
164
- try {
165
- ({ writtenPaths } = writeAndroidReportFiles({ outDir: reportsDir, prefix, report: reportModel, formats: config.formats }));
166
- }
167
- catch (err) {
168
- const msg = err instanceof Error ? err.message : String(err);
169
- console.error(`\nERROR: Failed to write Android report files: ${msg}`);
170
- console.error("Validation completed but the report could not be written. The in-memory result was not persisted.");
171
- process.exitCode = 4;
172
- process.exit(4);
173
- }
174
- console.log(textReport);
175
- console.log(`\nReports written:`);
176
- for (const p of writtenPaths) {
177
- console.log(` ${p}`);
178
- }
179
- const blockerExists = result.verdict === "not-ready-security-blocker-remains";
180
- const inconclusive = result.verdict === "inconclusive-audit-environment-incomplete";
181
- if (blockerExists) {
182
- console.error("\nExit 1 — security blocker remains.");
183
- process.exitCode = 1;
184
- }
185
- else if (inconclusive) {
186
- console.warn("\nExit 2 — android environment incomplete.");
187
- process.exitCode = 2;
188
- }
189
- else {
190
- console.log("\nExit 0 — validation completed.");
191
- process.exitCode = 0;
192
- }
193
- }
194
- else {
195
- // ---------------------------------------------------------------------------
196
- // Classic check-group/attack-scenario pipeline (unchanged from prior versions).
197
- // ---------------------------------------------------------------------------
198
- if (!config.checksWereDefault) {
199
- console.log(`Checks : ${config.checks.join(", ")}`);
200
- }
201
- if (config.plannedChecksRequested.length > 0) {
202
- console.log(`Note : ${config.plannedChecksRequested.join(", ")} are routed through the attack-scenario framework rather than the classic check-group runners. Review the attack-scenario section in the report for their concrete results.`);
203
- }
204
- console.log("");
205
- const summary = await runSecurityValidation({
206
- cwd: toolRoot,
207
- targetPath: args.target,
208
- fuzzIterations: parseInt(process.env["FUZZ_ITERATIONS"] ?? "50", 10),
209
- fuzzSeed: parseInt(process.env["FUZZ_SEED"] ?? "0xDEADBEEF", 16),
210
- // Full selection (implemented + planned/attack-scenario ids) — the runner
211
- // gates both implemented check groups and attack-scenario checks off the
212
- // same selectedChecks set.
213
- selectedChecks: config.checks,
214
- profile: config.profile,
215
- });
216
- // v0.2.2 Batch 5: --fail-on breach is additive to (never a substitute for)
217
- // the existing verdict-based exit decision below — it can only escalate
218
- // exit 0 to exit 1 (e.g. --fail-on medium/low catching minor/informational
219
- // findings the verdict policy doesn't already treat as blocking), never
220
- // downgrade an existing blocker.
221
- const failOnBreached = findingsBreachFailOnThreshold(summary.findings, config.failOnThreshold);
222
- // Build report object
223
- const report = buildSecurityReportFromSummary(summary, {
224
- profile: config.profile,
225
- selectedChecks: config.checks,
226
- failOnThreshold: config.failOnThreshold,
227
- formats: config.formats,
228
- failOnBreached,
229
- });
230
- const textReport = renderTextReport(report);
231
- // Determine output directory
232
- const reportsDir = config.out;
233
- // Determine report filename prefix
234
- const prefix = args.reportPrefix ?? reportFilenamePrefix(target);
235
- const { writtenPaths } = writeSecurityReportFiles({
236
- outDir: reportsDir,
237
- prefix,
238
- report,
239
- formats: config.formats,
240
- });
241
- // Print report to stdout
242
- console.log(textReport);
243
- console.log(`\nReports written:`);
244
- for (const p of writtenPaths) {
245
- console.log(` ${p}`);
246
- }
247
- // Exit code based on verdict, escalated (never downgraded) by --fail-on.
248
- const blockerExists = summary.verdict === "not-ready-security-blocker-remains";
249
- const inconclusive = summary.verdict === "inconclusive-audit-environment-incomplete";
250
- if (blockerExists) {
251
- console.error("\nExit 1 — security blocker remains.");
252
- process.exitCode = 1;
253
- }
254
- else if (inconclusive) {
255
- console.warn("\nExit 2 — audit environment incomplete.");
256
- process.exitCode = 2;
257
- }
258
- else if (failOnBreached) {
259
- console.error(`\nExit 1 — --fail-on ${config.failOnThreshold} threshold breached.`);
260
- process.exitCode = 1;
261
- }
262
- else {
263
- console.log("\nExit 0 — validation completed.");
264
- process.exitCode = 0;
265
- }
266
- }