Skip to content

Commit 7f5898b

Browse files
committed
chore: added component analysis
Signed-off-by: Tomer Figenblat <tfigenbl@redhat.com>
1 parent 64443ba commit 7f5898b

File tree

14 files changed

+306
-35
lines changed

14 files changed

+306
-35
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
coverage
33
node_modules
44
dist
5+
http_requests
6+
json_responses
57
integration/**/package-lock.json
68
unit-tests-result.json

integration/expected_component

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
[
2+
{
3+
"ref": {
4+
"name": "log4j:log4j",
5+
"version": "1.2.17"
6+
},
7+
"issues": [
8+
{
9+
"id": "SNYK-JAVA-LOG4J-572732",
10+
"source": "snyk",
11+
"cves": [
12+
"CVE-2019-17571"
13+
],
14+
"rawData": {
15+
"id": "SNYK-JAVA-LOG4J-572732",
16+
"title": "Deserialization of Untrusted Data",
17+
"CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:P",
18+
"cvssScore": 9.8
19+
}
20+
},
21+
{
22+
"id": "SNYK-JAVA-LOG4J-572732",
23+
"source": "snyk",
24+
"cves": [
25+
"CVE-2019-17571"
26+
],
27+
"rawData": {
28+
"id": "SNYK-JAVA-LOG4J-572732",
29+
"title": "Deserialization of Untrusted Data",
30+
"CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:P",
31+
"cvssScore": 9.8
32+
}
33+
},
34+
{
35+
"id": "SNYK-JAVA-LOG4J-2342645",
36+
"source": "snyk",
37+
"cves": [
38+
"CVE-2022-23305"
39+
],
40+
"rawData": {
41+
"id": "SNYK-JAVA-LOG4J-2342645",
42+
"title": "SQL Injection",
43+
"CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H",
44+
"cvssScore": 8.1
45+
}
46+
},
47+
{
48+
"id": "SNYK-JAVA-LOG4J-2342646",
49+
"source": "snyk",
50+
"cves": [
51+
"CVE-2022-23307"
52+
],
53+
"rawData": {
54+
"id": "SNYK-JAVA-LOG4J-2342646",
55+
"title": "Deserialization of Untrusted Data",
56+
"CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H",
57+
"cvssScore": 8.1
58+
}
59+
},
60+
{
61+
"id": "SNYK-JAVA-LOG4J-2342647",
62+
"source": "snyk",
63+
"cves": [
64+
"CVE-2022-23302"
65+
],
66+
"rawData": {
67+
"id": "SNYK-JAVA-LOG4J-2342647",
68+
"title": "Deserialization of Untrusted Data",
69+
"CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H",
70+
"cvssScore": 8.1
71+
}
72+
},
73+
{
74+
"id": "SNYK-JAVA-LOG4J-2342645",
75+
"source": "snyk",
76+
"cves": [
77+
"CVE-2022-23305"
78+
],
79+
"rawData": {
80+
"id": "SNYK-JAVA-LOG4J-2342645",
81+
"title": "SQL Injection",
82+
"CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H",
83+
"cvssScore": 8.1
84+
}
85+
},
86+
{
87+
"id": "SNYK-JAVA-LOG4J-2342646",
88+
"source": "snyk",
89+
"cves": [
90+
"CVE-2022-23307"
91+
],
92+
"rawData": {
93+
"id": "SNYK-JAVA-LOG4J-2342646",
94+
"title": "Deserialization of Untrusted Data",
95+
"CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H",
96+
"cvssScore": 8.1
97+
}
98+
},
99+
{
100+
"id": "SNYK-JAVA-LOG4J-2342647",
101+
"source": "snyk",
102+
"cves": [
103+
"CVE-2022-23302"
104+
],
105+
"rawData": {
106+
"id": "SNYK-JAVA-LOG4J-2342647",
107+
"title": "Deserialization of Untrusted Data",
108+
"CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H",
109+
"cvssScore": 8.1
110+
}
111+
},
112+
{
113+
"id": "SNYK-JAVA-LOG4J-2316893",
114+
"source": "snyk",
115+
"cves": [
116+
"CVE-2021-4104"
117+
],
118+
"rawData": {
119+
"id": "SNYK-JAVA-LOG4J-2316893",
120+
"title": "Arbitrary Code Execution",
121+
"CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H/E:P",
122+
"cvssScore": 6.6
123+
}
124+
},
125+
{
126+
"id": "SNYK-JAVA-LOG4J-2316893",
127+
"source": "snyk",
128+
"cves": [
129+
"CVE-2021-4104"
130+
],
131+
"rawData": {
132+
"id": "SNYK-JAVA-LOG4J-2316893",
133+
"title": "Arbitrary Code Execution",
134+
"CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H/E:P",
135+
"cvssScore": 6.6
136+
}
137+
},
138+
{
139+
"id": "SNYK-JAVA-LOG4J-3358774",
140+
"source": "snyk",
141+
"cves": [
142+
"CVE-2023-26464"
143+
],
144+
"rawData": {
145+
"id": "SNYK-JAVA-LOG4J-3358774",
146+
"title": "Denial of Service (DoS)",
147+
"CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H",
148+
"cvssScore": 5.9
149+
}
150+
},
151+
{
152+
"id": "SNYK-JAVA-LOG4J-3358774",
153+
"source": "snyk",
154+
"cves": [
155+
"CVE-2023-26464"
156+
],
157+
"rawData": {
158+
"id": "SNYK-JAVA-LOG4J-3358774",
159+
"title": "Denial of Service (DoS)",
160+
"CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H",
161+
"cvssScore": 5.9
162+
}
163+
},
164+
{
165+
"id": "SNYK-JAVA-LOG4J-1300176",
166+
"source": "snyk",
167+
"cves": [
168+
"CVE-2020-9488"
169+
],
170+
"rawData": {
171+
"id": "SNYK-JAVA-LOG4J-1300176",
172+
"title": "Man-in-the-Middle (MitM)",
173+
"CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N",
174+
"cvssScore": 3.7
175+
}
176+
},
177+
{
178+
"id": "SNYK-JAVA-LOG4J-1300176",
179+
"source": "snyk",
180+
"cves": [
181+
"CVE-2020-9488"
182+
],
183+
"rawData": {
184+
"id": "SNYK-JAVA-LOG4J-1300176",
185+
"title": "Man-in-the-Middle (MitM)",
186+
"CVSSv3": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N",
187+
"cvssScore": 3.7
188+
}
189+
}
190+
],
191+
"transitive": [],
192+
"securityRecommendations": {},
193+
"recommendation": null
194+
}
195+
]

integration/run_it.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ echo "- SUCCESSFUL"
3131
###### JavaScript Integration Tests ######
3232
##########################################
3333
echo "PREPARING JavaScript integration tests environment"
34-
if ! npm --prefix javascript install --force --silent
34+
rm -rf javascript/node_modules
35+
if ! npm --prefix javascript install --silent
3536
then
3637
echo "- FAILED Installing modules for JS environment"
3738
exit $?
@@ -44,17 +45,22 @@ match "expected_stack_html" "node javascript/index.js stack pom.xml true"
4445
echo "RUNNING JavaScript integration test for Stack Analysis report in Json"
4546
match "expected_stack_json" "node javascript/index.js stack pom.xml false"
4647

48+
echo "RUNNING JavaScript integration test for Component Analysis report"
49+
match "expected_component" "node javascript/index.js component pom.xml '$(<pom.xml)'"
50+
4751
##########################################
4852
###### TypeScript Integration Tests ######
4953
##########################################
5054
echo "PREPARING TypeScript integration tests environment"
51-
if ! npm --prefix typescript install --force --silent
55+
rm -rf typescript/node_modules
56+
if ! npm --prefix typescript install --silent
5257
then
5358
echo "- FAILED Installing modules for TS environment"
5459
exit $?
5560
fi
5661
echo "- SUCCESSFUL"
5762

63+
rm -rf typescript/dist
5864
if ! npm --prefix typescript run compile > /dev/null 2>&1
5965
then
6066
echo "- FAILED Compiling TS module"
@@ -67,11 +73,15 @@ match "expected_stack_html" "node typescript/dist/index.js stack pom.xml true"
6773
echo "RUNNING TypeScript integration test for Stack Analysis report in Json"
6874
match "expected_stack_json" "node typescript/dist/index.js stack pom.xml false"
6975

76+
echo "RUNNING TypeScript integration test for Component Analysis report"
77+
match "expected_component" "node typescript/dist/index.js component pom.xml '$(<pom.xml)'"
78+
7079
##########################################
7180
###### CMD Script Integration Tests ######
7281
##########################################
7382
echo "PREPARING CLI Script integration tests environment"
74-
if ! npm --prefix cli install --force --silent
83+
rm -rf cli/node_modules
84+
if ! npm --prefix cli install --silent
7585
then
7686
echo "- FAILED Installing modules for JS environment"
7787
exit $?
@@ -86,3 +96,6 @@ match "expected_stack_json" "node cli/node_modules/@RHEcosystemAppEng/crda-javas
8696

8797
echo "RUNNING CLI Script integration test for Stack Analysis report in full Json"
8898
match "expected_stack_json_summary" "node cli/node_modules/@RHEcosystemAppEng/crda-javascript-api/dist/src/cli.js stack pom.xml --summary"
99+
100+
echo "RUNNING CLI Script integration test for Component Analysis report"
101+
match "expected_component" "node cli/node_modules/@RHEcosystemAppEng/crda-javascript-api/dist/src/cli.js component pom.xml '$(<pom.xml)'"

package-lock.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,12 @@ const component = {
1919
desc: 'content of the manifest',
2020
type: 'string',
2121
}
22-
).options({
23-
summary: {
24-
alias: 's',
25-
desc: 'For JSON report, get only the \'summary\'',
26-
type: 'boolean',
27-
}
28-
}),
22+
),
2923
handler: async args => {
3024
let manifestName = args['manifest-name']
3125
let manifestContent = args['manifest-content']
32-
let summary = args['summary']
3326
let res = await crda.componentAnalysis(manifestName, manifestContent)
34-
console.log(JSON.stringify(
35-
summary ? res['summary'] : res,
36-
null,
37-
2))
27+
console.log(JSON.stringify(res, null, 2))
3828
}
3929
}
4030

0 commit comments

Comments
 (0)