Skip to content

Conversation

prabhu
Copy link
Collaborator

@prabhu prabhu commented Jun 26, 2025

Fixes #1909
Fixes #1964

Added a couple of environment variables (!), CDXGEN_ALLOWED_HOSTS and CDXGEN_ALLOWED_COMMANDS to accept comma-separated allowed values. Another environment variable CDXGEN_TRACE_MODE can be used to simply trace the commands executed and remote hosts accessed (especially with FETCH_LICENSE).

@prabhu
Copy link
Collaborator Author

prabhu commented Jun 26, 2025

CDXGEN_ALLOWED_HOSTS=localhost,*.maven.org FETCH_LICENSE=true CDXGEN_TRACE_ID=foo node ~/work/cyclonedx/cdxgen/bin/cdxgen.js -t java --json-pretty -o bom.json $(pwd)                                                                           (base)
{"traceId":"foo","timestamp":"2025-06-26T21:38:41.960Z","type":"spawn","command":"mvn","args":["dependency:tree","-N","-DoutputFile=/var/folders/sj/g0xj1gyn05qcvc6r3j3syg6h0000gn/T/cdxmvn-nW2AV7/mvn-parent-tree.txt"],"cwd":"/Users/prabhu/sandbox/java-sec-code"}
{"traceId":"foo","timestamp":"2025-06-26T21:38:43.260Z","type":"spawn","command":"mvn","args":["dependency:tree","-DoutputFile=/var/folders/sj/g0xj1gyn05qcvc6r3j3syg6h0000gn/T/cdxmvn-nW2AV7/mvn-tree.txt"],"cwd":"/Users/prabhu/sandbox/java-sec-code"}
{"traceId":"foo","timestamp":"2025-06-26T21:38:44.682Z","type":"http","protocol":"https:","host":"repo1.maven.org","pathname":"/maven2/org/springframework/boot/spring-boot-starter-web/1.5.1.RELEASE/spring-boot-starter-web-1.5.1.RELEASE.pom"}
{"traceId":"foo","timestamp":"2025-06-26T21:38:44.911Z","type":"http","protocol":"https:","host":"repo1.maven.org","pathname":"/maven2/org/springframework/boot/spring-boot-starters/1.5.1.RELEASE/spring-boot-starters-1.5.1.RELEASE.pom"}
{"traceId":"foo","timestamp":"2025-06-26T21:38:44.961Z","type":"http","protocol":"https:","host":"repo1.maven.org","pathname":"/maven2/org/springframework/boot/spring-boot-starter-web/1.5.1.RELEASE/spring-boot-starter-web-1.5.1.RELEASE.pom"}
{"traceId":"foo","timestamp":"2025-06-26T21:38:44.962Z","type":"http","protocol":"https:","host":"repo1.maven.org","pathname":"/maven2/org/springframework/boot/spring-boot-starter/1.5.1.RELEASE/spring-boot-starter-1.5.1.RELEASE.pom"}
{"traceId":"foo","timestamp":"2025-06-26T21:38:45.007Z","type":"http","protocol":"https:","host":"repo1.maven.org","pathname":"/maven2/org/springframework/boot/spring-boot-starters/1.5.1.RELEASE/spring-boot-starters-1.5.1.RELEASE.pom"}
{"traceId":"foo","timestamp":"2025-06-26T21:38:45.008Z","type":"http","protocol":"https:","host":"repo1.maven.org","pathname":"/maven2/org/springframework/boot/spring-boot-starter/1.5.1.RELEASE/spring-boot-starter-1.5.1.RELEASE.pom"}
{"traceId":"foo","timestamp":"2025-06-26T21:38:45.009Z","type":"http","protocol":"https:","host":"repo1.maven.org","pathname":"/maven2/org/springframework/boot/spring-boot/1.5.1.RELEASE/spring-boot-1.5.1.RELEASE.pom"}
{"traceId":"foo","timestamp":"2025-06-26T21:38:45.062Z","type":"http","protocol":"https:","host":"repo1.maven.org","pathname":"/maven2/org/springframework/boot/spring-boot-parent/1.5.1.RELEASE/spring-boot-parent-1.5.1.RELEASE.pom"}
{"traceId":"foo","timestamp":"2025-06-26T21:38:45.126Z","type":"http","protocol":"https:","host":"repo1.maven.org","pathname":"/maven2/org/springframework/boot/spring-boot/1.5.1.RELEASE/spring-boot-1.5.1.RELEASE.pom"}

@prabhu
Copy link
Collaborator Author

prabhu commented Jun 26, 2025

CDXGEN_ALLOWED_HOSTS=localhost FETCH_LICENSE=true CDXGEN_TRACE_ID=foo node ~/work/cyclonedx/cdxgen/bin/cdxgen.js -t java --json-pretty -o bom.json $(pwd)                                                                                       (base)
{"traceId":"foo","timestamp":"2025-06-26T21:38:16.329Z","type":"spawn","command":"mvn","args":["dependency:tree","-N","-DoutputFile=/var/folders/sj/g0xj1gyn05qcvc6r3j3syg6h0000gn/T/cdxmvn-6UtQQ1/mvn-parent-tree.txt"],"cwd":"/Users/prabhu/sandbox/java-sec-code"}
{"traceId":"foo","timestamp":"2025-06-26T21:38:17.672Z","type":"spawn","command":"mvn","args":["dependency:tree","-DoutputFile=/var/folders/sj/g0xj1gyn05qcvc6r3j3syg6h0000gn/T/cdxmvn-6UtQQ1/mvn-tree.txt"],"cwd":"/Users/prabhu/sandbox/java-sec-code"}
Access to the remote host 'repo1.maven.org' is not permitted.

@prabhu
Copy link
Collaborator Author

prabhu commented Jun 27, 2025

  • Run cdxgen in trace mode and document the commands and remote hosts usually accessed for the given language types.

prabhu added 8 commits June 30, 2025 13:16
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
@prabhu prabhu force-pushed the feature/allowlist-trace-all branch from 6e5a7ac to 651403c Compare June 30, 2025 12:16
@prabhu
Copy link
Collaborator Author

prabhu commented Jun 30, 2025

Will merge this so that we can continue testing against master and with the container images.

@prabhu prabhu merged commit 86302e0 into master Jun 30, 2025
79 checks passed
@prabhu prabhu deleted the feature/allowlist-trace-all branch June 30, 2025 12:35
malice00 pushed a commit that referenced this pull request Jul 1, 2025
* Allowlists for commands and remote hosts

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>

* Fix grammar

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>

* Display allowlist suggestion

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>

* CRLF and gitconfig injection mitigation

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>

* Fixes #1953 and #1962

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>

* Recreate lock file

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>

* Only allow https protocol in secure mode

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>

---------

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment