Skip to content

Commit 42681a1

Browse files
authored
Merge pull request #100 from CycloneDX/gron
Add gron to docker image and add example usage
2 parents 0a83b52 + cba5307 commit 42681a1

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,11 @@ FROM mcr.microsoft.com/dotnet/runtime-deps:5.0
22

33
COPY bin/linux-x64/cyclonedx /cyclonedx
44

5+
ADD https://github.com/tomnomnom/gron/releases/download/v0.6.1/gron-linux-amd64-0.6.1.tgz /tmp/gron.tgz
6+
7+
RUN tar xzf /tmp/gron.tgz \
8+
&& mv ./gron /usr/local/bin/ \
9+
&& rm /tmp/gron.tgz
10+
511
ENTRYPOINT [ "/cyclonedx" ]
612
CMD [ "--help" ]

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ Options:
110110
--fail-on-errors Fail on validation errors (return a non-zero exit code)
111111
```
112112

113-
## Docker Image
113+
# Docker Image
114114

115115
The CycloneDX CLI tool can also be run using docker `docker run cyclonedx/cyclonedx-cli`.
116116

117-
## Supported Platforms
117+
# Supported Platforms
118118

119119
Officially supported builds are available for these platforms:
120120

@@ -136,3 +136,35 @@ Community supported builds are available for these platforms:
136136
For Windows these should be preinstalled.
137137

138138
For Ubuntu these are libc6 libgcc1 libgssapi-krb5-2 libicu66 libssl1.1 libstdc++6 zlib1g.
139+
140+
# Using gron for adhoc searching and analysis
141+
142+
gron transforms JSON into discrete assignments to make it easier to grep for what you want and see the absolute 'path' to it.
143+
144+
For convenience, gron is included in the CycloneDX CLI Docker image.
145+
146+
Example usage that lists all component names and versions
147+
148+
```
149+
$ gron bom-1.2.json | grep -E "(components\[[[:digit:]]*\].name)|(components\[[[:digit:]]*\].version)"
150+
151+
json.components[0].name = "tomcat-catalina";
152+
json.components[0].version = "9.0.14";
153+
json.components[1].name = "mylibrary";
154+
json.components[1].version = "1.0.0";
155+
```
156+
157+
Or the same using an XML format SBOM
158+
159+
```
160+
$ cyclonedx convert --input-file bom.xml --output-format json | gron | grep -E "(components\[[[:digit:]]*\].name)|(components\[[[:digit:]]*\].version)"
161+
162+
json.components[0].name = "tomcat-catalina";
163+
json.components[0].version = "9.0.14";
164+
json.components[1].name = "mylibrary";
165+
json.components[1].version = "1.0.0";
166+
```
167+
168+
For more details on gron usage refer to the [gron project page](https://github.com/TomNomNom/gron).
169+
170+
For more details on grep usage refer to the [grep man page](https://www.man7.org/linux/man-pages/man1/grep.1.html).

0 commit comments

Comments
 (0)