-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathsbom_generation.yaml
More file actions
119 lines (116 loc) · 5.19 KB
/
Copy pathsbom_generation.yaml
File metadata and controls
119 lines (116 loc) · 5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Copyright (c) 2023-2024, Oracle and/or its affiliates. All rights reserved.
# This OCI DevOps build specification file [1] generates a Software Bill of Materials (SBOM) of the repository.
# The file is needed to run checks for third-party vulnerabilities and business approval according to Oracle’s GitHub policies.
# [1] https://docs.oracle.com/en-us/iaas/Content/devops/using/build_specs.htm
version: 0.1
component: build
timeoutInSeconds: 3600
shell: bash
steps:
- type: Command
name: "Install Java 17 "
command: |
uname -a
JDK_VERSION=17.0.19+10
JDK_TARFILE=`echo "OpenJDK17U-jdk_x64_linux_hotspot_$JDK_VERSION.tar.gz" | cut -d '+' --output-delimiter=_ -f 1-`
# Download JDK
wget -O $JDK_TARFILE https://github.com/adoptium/temurin17-binaries/releases/download/jdk-$JDK_VERSION/$JDK_TARFILE
# Verify sha sum
wget -O - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-$JDK_VERSION/$JDK_TARFILE.sha256.txt | sha256sum -c -
# Extract JDK
tar -xzf $JDK_TARFILE -C ${OCI_PRIMARY_SOURCE_DIR}
mv ${OCI_PRIMARY_SOURCE_DIR}/jdk-$JDK_VERSION ${OCI_PRIMARY_SOURCE_DIR}/jdk-17
- type: Command
name: "Install Ant "
command: |
ANT_VERSION=1.10.17
ANT_TARFILE=apache-ant-$ANT_VERSION-bin.tar.bz2
# Download ant
wget -O $ANT_TARFILE https://dlcdn.apache.org/ant/binaries/$ANT_TARFILE
# Verify sha sum
printf '%s\t%s\n' "`wget -O - https://downloads.apache.org/ant/binaries/$ANT_TARFILE.sha512`" "$ANT_TARFILE" | sha512sum -c -
# Extract ant
tar -xjf $ANT_TARFILE -C ${OCI_PRIMARY_SOURCE_DIR}
mv ${OCI_PRIMARY_SOURCE_DIR}/apache-ant-$ANT_VERSION ${OCI_PRIMARY_SOURCE_DIR}/ant
- type: Command
name: "Update git"
command: |
yum update git
- type: Command
name: "Checkout submodules"
command: |
git submodule update --init --recursive
- type: Command
name: "Download cdxgen globally with workaround to run on older nodejs"
command: |
# cdxgen relies on a fourth-party dependency that cannot be executed in a Node.js environment running version 16
# This is a workaround to ensure cdxgen functions correctly, even in an older Node.js environment.
npm install -g @cyclonedx/cdxgen@9.8.8 && \
cd $(dirname $(which node) | sed -e 's:/bin$:/lib:')/node_modules/@cyclonedx/cdxgen && \
npm install cheerio@v1.0.0-rc.12 && \
cdxgen --version && \
cd - && \
cdxgen ${OCI_PRIMARY_SOURCE_DIR}/ant/lib --type jar -r --required-only -o test-bom.json --json-pretty --spec-version 1.4 && \
rm -f test-bom.json
- type: Command
name: "Install npm dependencies"
command: |
cd vscode
npm install
- type: Command
name: "Install and run cyclonedx-node-npm package"
command: |
cd vscode
# For more details, visit https://github.com/CycloneDX/cyclonedx-node-npm/blob/main/README.md
npm install --no-save @cyclonedx/cyclonedx-npm@1.20.0 && \
npx @cyclonedx/cyclonedx-npm --omit dev --output-format JSON --output-file ../bom-vscode.json --spec-version 1.4
- type: Command
name: "Download CycloneDx-cli executable and install dependencies for final merged artifacts"
command: |
wget https://github.com/CycloneDX/cyclonedx-cli/releases/download/v0.24.2/cyclonedx-linux-x64 && \
chmod +x cyclonedx-linux-x64 && \
yum install -y libicu jq && \
./cyclonedx-linux-x64 --version
- type: Command
name: "Build netbeans"
command: |
export JAVA_HOME=${OCI_PRIMARY_SOURCE_DIR}/jdk-17
export ANT_HOME=${OCI_PRIMARY_SOURCE_DIR}/ant
export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
ant apply-patches
ant build-netbeans
- type: Command
name: "Build vscode extension "
command: |
export JAVA_HOME=${OCI_PRIMARY_SOURCE_DIR}/jdk-17
export ANT_HOME=${OCI_PRIMARY_SOURCE_DIR}/ant
export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
ant build-lsp-server
- type: Command
name: "Generate sbom for the nbcode part"
command: |
export SEARCH_MAVEN_ORG=false
export CDXGEN_DEBUG_MODE=debug
cd vscode
# For more details, visit https://github.com/CycloneDX/cdxgen/blob/master/README.md
cdxgen nbcode/ --type jar -r --required-only -o ../bom-nbcode.json --json-pretty --spec-version 1.4
- type: Command
name: "Merge multiple SBOMs using CycloneDX-cli"
command: |
# For more details, visit https://github.com/CycloneDX/cyclonedx-cli/blob/main/README.md
./cyclonedx-linux-x64 merge --input-files bom-vscode.json bom-nbcode.json --output-file merged-bom.json
# This step is optional for when you need to specify the name of your modules
- type: Command
name: "Detect the metadata components of the SBOMs"
command: |
for path in bom-vscode.json bom-nbcode.json; do
jq -r '.metadata.component.purl' $path >> ${OCI_PRIMARY_SOURCE_DIR}/metadataComponentPurls.txt;
done
outputArtifacts:
- name: artifactSBOM
type: BINARY
location: ${OCI_PRIMARY_SOURCE_DIR}/merged-bom.json
# This step is optional for when you need to specify the name of your modules
- name: metadataComponentPurls
type: BINARY
location: ${OCI_PRIMARY_SOURCE_DIR}/metadataComponentPurls.txt