Skip to content

Commit 18b8a35

Browse files
VinnyBartonccYHM86Cosimo Commisso
authored
Bump version to 3.0.0 (#14)
* Merged in PIPES-11_FixGitHubActions (pull request #19) PIPES-11: fix docker build action * PIPES-11: fix docker build action * Merged in feb_2024_updates (pull request #20) Feb 2024 updates * Feb 2024 updates * Feb 2024 updates * Feb 2024 updates * merge with github * Merged in optimizeDockerImage (pull request #22) OptimizeDockerImage * optimize Dockerfile * optimize Dockerfile & pipeline * Merged in May2024_Updates (pull request #23) June 2024 Updates * fix code coverage * fix code coverage * update version in README.md * Merged in dec_2024_updates (pull request #24) Update @cyclonedx/cyclonedx-npm to 1.19.3 * Update @cyclonedx/cyclonedx-npm to 1.19.3 * Update sbom gen pipeline * v1.6.0 release * Merged in addSonarIntegration (pull request #25) add support for sonarcloud * add support for sonarcloud * add support for sonarcloud * Merged in addBadges (pull request #26) add badges to README * add badges to README * Merged in Jan2024Updates (pull request #27) January 2024 Updates * January 2024 Updates * Merged in rel-v2.0.0 (pull request #28) Bump version to 2.0.0 * Bump version to 2.0.0 * Merged in useOSSFNaming (pull request #29) Standardize SBOM naming per OSSF guidelines * Standardize SBOM naming per OSSF guidelines * Standardize SBOM naming per OSSF guidelines * bump version to 3.0.0 --------- Co-authored-by: Cosimo Commisso <[email protected]> Co-authored-by: Cosimo Commisso <[email protected]>
1 parent 4fd95e4 commit 18b8a35

File tree

8 files changed

+45
-20
lines changed

8 files changed

+45
-20
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ARG ARCH
55
# hadolint ignore=DL3018
66
RUN apk update \
77
&& apk upgrade \
8-
&& apk --no-cache add bash
8+
&& apk --no-cache add bash jq
99

1010
SHELL ["/bin/bash", "-c"]
1111

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ test:
99
$(DOCKER) run --rm -it \
1010
-v $(PWD):/build \
1111
--workdir /build \
12-
bats/bats:1.9.0 test/**.bats --timing --show-output-of-passing-tests --verbose-run
12+
bats/bats:1.11.0 test/**.bats --timing --show-output-of-passing-tests --verbose-run
1313

1414
.PHONY: shellcheck
1515
shellcheck:
1616
$(DOCKER) run --rm -it \
1717
-v $(PWD):/build \
1818
--workdir /build \
19-
koalaman/shellcheck-alpine:v0.9.0 shellcheck -x ./*.sh ./**/*.bats
19+
koalaman/shellcheck-alpine:v0.10.0 shellcheck -x ./*.sh ./**/*.bats
2020

2121
.PHONY: clean
2222
clean:

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=ccideas1_cyclonedx-npm-pipe&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=ccideas1_cyclonedx-npm-pipe)
77
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=ccideas1_cyclonedx-npm-pipe&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=ccideas1_cyclonedx-npm-pipe)
88

9-
109
![Build Badge](https://img.shields.io/bitbucket/pipelines/ccideas1/cyclonedx-npm-pipe/main)
1110
![GitHub release (latest by date)](https://img.shields.io/github/v/release/shiftleftcyber/cyclonedx-npm-pipe)
1211

@@ -47,8 +46,7 @@ pipelines:
4746
caches:
4847
- node
4948
script:
50-
51-
- pipe: docker://ccideas/cyclonedx-npm-pipe:2.0.0
49+
- pipe: docker://ccideas/cyclonedx-npm-pipe:3.0.0
5250
variables:
5351
IGNORE_NPM_ERRORS: 'true' # optional
5452
NPM_SHORT_PURLS: 'true' # optional
@@ -73,7 +71,7 @@ pipelines:
7371
| NPM_OMIT | Used to omit specific dependency types | dev, optional, peer | none |
7472
| NPM_OUTPUT_FORMAT | Used to specify output format of the sBOM | json, xml | json |
7573
| NPM_PACKAGE_LOCK_ONLY | Used to use only the package-lock.json file to find dependencies | true, false | false |
76-
| OUTPUT_DIRECTORY | Used to specify the directory to place all output in | directory name | sbom_output |
74+
| OUTPUT_DIRECTORY | Used to specify the directory to place all output im | directory name | sbom_output |
7775
7876
## Details
7977

gen_sbom_functions.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#!/usr/bin/env bash
2+
3+
# shellcheck disable=SC2002
4+
# SC2002 (style): the cat command is used inside of jq
5+
26
set -e
37

48
# Statics
@@ -25,13 +29,14 @@ check_output_directory() {
2529

2630
set_sbom_filename() {
2731
check_output_directory
32+
get_package_version
2833

2934
if [ -n "${SBOM_FILENAME}" ]; then
3035
OUTPUT_FILENAME="${OUTPUT_DIR}/${SBOM_FILENAME}"
3136
elif [ -n "${BITBUCKET_REPO_SLUG}" ]; then
32-
OUTPUT_FILENAME="${OUTPUT_DIR}/${BITBUCKET_REPO_SLUG}"
37+
OUTPUT_FILENAME="${OUTPUT_DIR}/${BITBUCKET_REPO_SLUG}-${PACKAGE_VERSION}.cdx"
3338
else
34-
OUTPUT_FILENAME="${OUTPUT_DIR}/sbom"
39+
OUTPUT_FILENAME="${OUTPUT_DIR}/sbom-${PACKAGE_VERSION}.cdx"
3540
fi
3641

3742
# set the file extension
@@ -45,6 +50,19 @@ set_sbom_filename() {
4550
SWITCHES+=("--output-file" "${OUTPUT_FILENAME}")
4651
}
4752

53+
get_package_version() {
54+
get_version
55+
echo "package verison is is set to: ${PACKAGE_VERSION}"
56+
if [ "${PACKAGE_VERSION}" == "null" ]; then
57+
echo "WARNING: version field is not set in package.json"
58+
PACKAGE_VERSION=0.0.0
59+
fi
60+
}
61+
62+
get_version() (
63+
PACKAGE_VERSION=$(cat package.json | jq --raw-output .version)
64+
)
65+
4866
help() {
4967
echo "Generates a CycloneDX sBOM file for the given project"
5068
}

pipe.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: CycloneDX node/npm sBOM Generator
2-
image: shiftleftcyber/cyclonedx-npm-pipe:2.0.0
2+
image: shiftleftcyber/cyclonedx-npm-pipe:3.0.0
33
category: Security
44
description: Generates a CycloneDX compliant Software Bill of Materials for a node/npm project
55
repository: https://bitbucket.org/ccideas1/cyclonedx-npm-pipe/src/main/

sample.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
2-
"dependencies": {
3-
"axios": "^1.6.5"
4-
}
2+
"name": "ShiftSBOMGen-Node",
3+
"version": "0.0.1",
4+
"description": "Sample Project",
5+
"license": "MIT",
6+
"author": "ShiftLeftCyber",
7+
8+
"dependencies": {
9+
"axios": "^1.6.5"
510
}
6-
11+
}

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sonar.host.url=https://sonarcloud.io
22
sonar.orginization=ccideas
33
sonar.projectKey=ccideas1_cyclonedx-npm-pipe
4-
sonar.projectVersion=v2.0.0
4+
sonar.projectVersion=v3.0.0
55
sonar.sources=.

test/gen_sbom.bats

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ generate_cyclonedx_sbom_for_npm_project() {
2222
echo "mock of generate_cyclonedx_sbom_for_npm_project()"
2323
}
2424

25+
get_version() {
26+
export PACKAGE_VERSION=0.0.0
27+
}
28+
2529
#--------------------------------------------------------------------------------
2630
#---------------------------------------Tests------------------------------------
2731
#--------------------------------------------------------------------------------
@@ -80,7 +84,7 @@ generate_cyclonedx_sbom_for_npm_project() {
8084
unset OUTPUT_DIRECTORY
8185
run set_sbom_filename
8286

83-
[ "${lines[2]}" = "sBOM will be written to sbom_output/sbom.json" ]
87+
[ "${lines[3]}" = "sBOM will be written to sbom_output/sbom-0.0.0.cdx.json" ]
8488
[ "$status" -eq 0 ]
8589
}
8690

@@ -91,7 +95,7 @@ generate_cyclonedx_sbom_for_npm_project() {
9195

9296
run set_sbom_filename
9397

94-
[ "${lines[2]}" = "sBOM will be written to sbom_output/${BITBUCKET_REPO_SLUG}.json" ]
98+
[ "${lines[3]}" = "sBOM will be written to sbom_output/${BITBUCKET_REPO_SLUG}-0.0.0.cdx.json" ]
9599
[ "$status" -eq 0 ]
96100
}
97101

@@ -102,7 +106,7 @@ generate_cyclonedx_sbom_for_npm_project() {
102106

103107
run set_sbom_filename
104108

105-
[ "${lines[2]}" = "sBOM will be written to sbom_output/${SBOM_FILENAME}.json" ]
109+
[ "${lines[3]}" = "sBOM will be written to sbom_output/${SBOM_FILENAME}.json" ]
106110
[ "$status" -eq 0 ]
107111
}
108112

@@ -112,7 +116,7 @@ generate_cyclonedx_sbom_for_npm_project() {
112116

113117
run set_sbom_filename
114118

115-
[ "${lines[2]}" = "sBOM will be written to sbom_output/${BITBUCKET_REPO_SLUG}.xml" ]
119+
[ "${lines[3]}" = "sBOM will be written to sbom_output/${BITBUCKET_REPO_SLUG}-0.0.0.cdx.xml" ]
116120
[ "$status" -eq 0 ]
117121
}
118122

@@ -123,7 +127,7 @@ generate_cyclonedx_sbom_for_npm_project() {
123127

124128
run set_sbom_filename
125129

126-
[ "${lines[2]}" = "sBOM will be written to build/${BITBUCKET_REPO_SLUG}.xml" ]
130+
[ "${lines[3]}" = "sBOM will be written to build/${BITBUCKET_REPO_SLUG}-0.0.0.cdx.xml" ]
127131
[ "$status" -eq 0 ]
128132
}
129133

0 commit comments

Comments
 (0)