Skip to content

Commit c8a9ede

Browse files
committed
Updated sbom : Added the steps to create sbom for java (netbeans dependencies)
1 parent 08ae17b commit c8a9ede

File tree

1 file changed

+77
-4
lines changed

1 file changed

+77
-4
lines changed

sbom_generation.yaml

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,95 @@
66

77
version: 0.1
88
component: build
9-
timeoutInSeconds: 1000
9+
timeoutInSeconds: 3600
1010
shell: bash
1111

1212
steps:
13+
- type: Command
14+
name: "Install Java 17 "
15+
command: |
16+
yum install -y java-17-openjdk java-17-openjdk-devel
17+
- type: Command
18+
name: "Install Ant "
19+
command: |
20+
wget https://dlcdn.apache.org//ant/binaries/apache-ant-1.10.15-bin.tar.gz
21+
tar xzf apache-ant-1.10.15-bin.tar.gz -C ${OCI_PRIMARY_SOURCE_DIR}
22+
- type: Command
23+
name: "Update git"
24+
command: |
25+
yum update git
26+
- type: Command
27+
name: "Checkout submodules"
28+
command: |
29+
git submodule update --init --recursive
30+
- type: Command
31+
name: "Build netbeans"
32+
command: |
33+
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac))))
34+
export ANT_HOME=${OCI_PRIMARY_SOURCE_DIR}/apache-ant-1.10.15
35+
export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
36+
ant apply-patches
37+
ant build-netbeans
38+
- type: Command
39+
name: "Build vscode extension "
40+
command: |
41+
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac))))
42+
export ANT_HOME=${OCI_PRIMARY_SOURCE_DIR}/apache-ant-1.10.15
43+
export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
44+
ant build-lsp-server
45+
- type: Command
46+
name: "Download the version 10.10.0 of cdxgen globally"
47+
command: |
48+
npm install -g @cyclonedx/[email protected]
49+
- type: Command
50+
name: "Workaround to let cdxgen run on nodejs 16"
51+
command: |
52+
# cdxgen relies on a fourth-party dependency that cannot be executed in a Node.js environment running version 16
53+
# (as installed on the build runner instance)
54+
# This is a workaround to ensure cdxgen functions correctly, even in an older Node.js environment.
55+
cd /node/node-v16.14.2-linux-x64/lib/node_modules/@cyclonedx/cdxgen && \
56+
npm install [email protected]
57+
- type: Command
58+
name: "Generate sbom for the nbcode part"
59+
command: |
60+
cd vscode
61+
# For more details, visit https://github.com/CycloneDX/cdxgen/blob/master/README.md
62+
npx @cyclonedx/cdxgen nbcode/ -r --required-only -o ../bom-nbcode.json --json-pretty --spec-version 1.4
1363
- type: Command
1464
name: "Install dependencies & cyclonedx-node-npm package"
1565
command: |
1666
cd vscode
17-
npm install && npm install --save-dev @cyclonedx/[email protected]
67+
npm install && npm install --save-dev @cyclonedx/[email protected]
1868
- type: Command
1969
name: "Run cyclonedx-node-npm package"
2070
command: |
2171
cd vscode
2272
# For more details, visit https://github.com/CycloneDX/cyclonedx-node-npm/blob/main/README.md
23-
npx @cyclonedx/cyclonedx-npm --omit dev --output-format JSON --output-file ../artifactSBOM.json --spec-version 1.4
73+
npx @cyclonedx/cyclonedx-npm --omit dev --output-format JSON --output-file ../bom-vscode.json --spec-version 1.4
74+
- type: Command
75+
name: "Download CycloneDx-cli executable and install dependencies"
76+
command: |
77+
wget https://github.com/CycloneDX/cyclonedx-cli/releases/download/v0.24.2/cyclonedx-linux-x64
78+
yum install -y libicu
79+
- type: Command
80+
name: "Merge multiple SBOMs using CycloneDX-cli"
81+
command: |
82+
# For more details, visit https://github.com/CycloneDX/cyclonedx-cli/blob/main/README.md
83+
chmod +x cyclonedx-linux-x64
84+
./cyclonedx-linux-x64 merge --input-files bom-vscode.json bom-nbcode.json --output-file merged-bom.json
85+
# This step is optional for when you need to specify the name of your modules
86+
- type: Command
87+
name: "Detect the metadata components of the SBOMs"
88+
command: |
89+
yum install -y jq
90+
for path in bom-vscode.json bom-nbcode.json; do
91+
jq -r '.metadata.component.purl' "path" >> ${OCI_PRIMARY_SOURCE_DIR}/metadataComponentPurls.txt;
92+
done
2493
outputArtifacts:
2594
- name: artifactSBOM
2695
type: BINARY
27-
location: ${OCI_PRIMARY_SOURCE_DIR}/artifactSBOM.json
96+
location: ${OCI_PRIMARY_SOURCE_DIR}/merged-bom.json
97+
# This step is optional for when you need to specify the name of your modules
98+
- name: metadataComponentPurls
99+
type: BINARY
100+
location: ${OCI_PRIMARY_SOURCE_DIR}/metadataComponentPurls.txt

0 commit comments

Comments
 (0)