Skip to content

Commit 4391efd

Browse files
committed
bug:SP-1696 Fixes policy summary output
1 parent 6e9b75e commit 4391efd

File tree

7 files changed

+674
-12
lines changed

7 files changed

+674
-12
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Upcoming changes...
1111

12+
## [1.17.1] - 2024-10-24
13+
### Fixed
14+
- Fixed policy summary output
15+
1216
## [1.17.0] - 2024-10-23
1317
### Added
1418
- Added inspect subcommand
@@ -363,4 +367,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
363367
[1.14.0]: https://github.com/scanoss/scanoss.py/compare/v1.13.0...v1.14.0
364368
[1.15.0]: https://github.com/scanoss/scanoss.py/compare/v1.14.0...v1.15.0
365369
[1.16.0]: https://github.com/scanoss/scanoss.py/compare/v1.15.0...v1.16.0
366-
[1.17.0]: https://github.com/scanoss/scanoss.py/compare/v1.16.0...v1.17.0
370+
[1.17.0]: https://github.com/scanoss/scanoss.py/compare/v1.16.0...v1.17.0
371+
[1.17.1]: https://github.com/scanoss/scanoss.py/compare/v1.17.0...v1.17.1

src/scanoss/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
THE SOFTWARE.
2323
"""
2424

25-
__version__ = "1.17.0"
25+
__version__ = "1.17.1"

src/scanoss/inspection/copyleft.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def _json(self, components: list) -> Dict[str, Any]:
6969
if len(components) > 0:
7070
details = { 'components': components }
7171
return {
72-
'details': json.dumps(details, indent=2),
73-
'summary': f'{len(components)} component(s) with copyleft licenses were found.'
72+
'details': f'{json.dumps(details, indent=2)}\n',
73+
'summary': f'{len(components)} component(s) with copyleft licenses were found.\n'
7474
}
7575

7676
def _markdown(self, components: list) -> Dict[str,Any]:
@@ -96,8 +96,8 @@ def _markdown(self, components: list) -> Dict[str,Any]:
9696
# End license loop
9797
# End component loop
9898
return {
99-
'details': f'### Copyleft licenses\n{self.generate_table(headers,rows,centered_columns)}',
100-
'summary' : f'{len(components)} component(s) with copyleft licenses were found.'
99+
'details': f'### Copyleft licenses\n{self.generate_table(headers,rows,centered_columns)}\n',
100+
'summary' : f'{len(components)} component(s) with copyleft licenses were found.\n'
101101
}
102102

103103
def _filter_components_with_copyleft_licenses(self, components: list) -> list:

src/scanoss/inspection/undeclared_component.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def _get_summary(self, components: list) -> str:
7878
"""
7979
summary = f'{len(components)} undeclared component(s) were found.\n'
8080
if len(components) > 0:
81-
summary += (f' Add the following snippet into your `sbom.json` file \n'
82-
f' ```json \n {json.dumps(self._generate_sbom_file(components), indent=2)} ``` \n ')
81+
summary += (f'Add the following snippet into your `sbom.json` file\n'
82+
f'\n```json\n{json.dumps(self._generate_sbom_file(components), indent=2)}\n```\n')
8383
return summary
8484

8585
def _json(self, components: list) -> Dict[str, Any]:
@@ -93,7 +93,7 @@ def _json(self, components: list) -> Dict[str, Any]:
9393
if len(components) > 0:
9494
details = {'components': components}
9595
return {
96-
'details': json.dumps(details, indent=2),
96+
'details': f'{json.dumps(details, indent=2)}\n',
9797
'summary': self._get_summary(components),
9898
}
9999

@@ -111,7 +111,7 @@ def _markdown(self, components: list) -> Dict[str,Any]:
111111
licenses = " - ".join(lic.get('spdxid', 'Unknown') for lic in component['licenses'])
112112
rows.append([component['purl'], component['version'], licenses])
113113
return {
114-
'details': f'### Undeclared components\n{self.generate_table(headers,rows)}',
114+
'details': f'### Undeclared components\n{self.generate_table(headers,rows)}\n',
115115
'summary': self._get_summary(components),
116116
}
117117

tests/data/result-no-copyleft.json

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
{
2+
"inc/crc32c.h": [
3+
{
4+
"id": "none",
5+
"server": {
6+
"kb_version": {
7+
"daily": "24.08.16",
8+
"monthly": "24.07"
9+
},
10+
"version": "5.4.8"
11+
}
12+
}
13+
],
14+
"inc/json.h": [
15+
{
16+
"component": "scanner.c",
17+
"file": "scanner.c-1.3.3/external/inc/json.h",
18+
"file_hash": "e91a03b850651dd56dd979ba92668a19",
19+
"file_url": "https://api.osskb.org/file_contents/e91a03b850651dd56dd979ba92668a19",
20+
"id": "file",
21+
"latest": "1.3.4",
22+
"licenses": [],
23+
"lines": "all",
24+
"matched": "100%",
25+
"oss_lines": "all",
26+
"purl": [
27+
"pkg:github/scanoss/scanner.c"
28+
],
29+
"release_date": "2021-05-26",
30+
"server": {
31+
"kb_version": {
32+
"daily": "24.08.16",
33+
"monthly": "24.07"
34+
},
35+
"version": "5.4.8"
36+
},
37+
"source_hash": "e91a03b850651dd56dd979ba92668a19",
38+
"status": "pending",
39+
"url": "https://github.com/scanoss/scanner.c",
40+
"url_hash": "2d1700ba496453d779d4987255feb5f2",
41+
"url_stats": {},
42+
"vendor": "scanoss",
43+
"version": "1.3.3"
44+
}
45+
],
46+
"inc/log.h": [
47+
{
48+
"component": "scanner.c",
49+
"file": "scanner.c-1.1.4/external/inc/log.h",
50+
"file_hash": "36ae4f65e9302539357a64ddb8e35c28",
51+
"file_url": "https://api.osskb.org/file_contents/36ae4f65e9302539357a64ddb8e35c28",
52+
"id": "file",
53+
"latest": "1.3.4",
54+
"licenses": [],
55+
"lines": "all",
56+
"matched": "100%",
57+
"oss_lines": "all",
58+
"purl": [
59+
"pkg:github/scanoss/scanner.c"
60+
],
61+
"release_date": "2021-01-11",
62+
"server": {
63+
"kb_version": {
64+
"daily": "24.08.16",
65+
"monthly": "24.07"
66+
},
67+
"version": "5.4.8"
68+
},
69+
"source_hash": "36ae4f65e9302539357a64ddb8e35c28",
70+
"status": "pending",
71+
"url": "https://github.com/scanoss/scanner.c",
72+
"url_hash": "1dcd883dc73d16f3ce2cf4f1f9854c7b",
73+
"url_stats": {},
74+
"vendor": "scanoss",
75+
"version": "1.1.4"
76+
}
77+
],
78+
"inc/winnowing.h": [
79+
{
80+
"component": "engine",
81+
"file": "external/inc/winnowing.h",
82+
"file_hash": "d58b03e8ef411204db0fb991f778444a",
83+
"file_url": "https://api.osskb.org/file_contents/d58b03e8ef411204db0fb991f778444a",
84+
"id": "file",
85+
"latest": "5.4.8",
86+
"licenses": [],
87+
"lines": "all",
88+
"matched": "100%",
89+
"oss_lines": "all",
90+
"purl": [
91+
"pkg:github/scanoss/engine"
92+
],
93+
"release_date": "2024-02-27",
94+
"server": {
95+
"kb_version": {
96+
"daily": "24.08.16",
97+
"monthly": "24.07"
98+
},
99+
"version": "5.4.8"
100+
},
101+
"source_hash": "d58b03e8ef411204db0fb991f778444a",
102+
"status": "identified",
103+
"url": "https://github.com/scanoss/engine",
104+
"url_hash": "5107cd431b8b6c7836c84e997bab01ec",
105+
"url_stats": {},
106+
"vendor": "scanoss",
107+
"version": "5.4.0"
108+
}
109+
],
110+
"src/crc32c.c": [
111+
{
112+
"component": "wfp",
113+
"file": "wfp-6afc1f6163d1d6c8d03ff5211a0571118e08da1f/src/external/crc32c/crc32c.c",
114+
"file_hash": "0fe279946d388ef07d9c3f6e3ffb8ebe",
115+
"file_url": "https://api.osskb.org/file_contents/0fe279946d388ef07d9c3f6e3ffb8ebe",
116+
"id": "file",
117+
"latest": "0ed473d",
118+
"licenses": [],
119+
"lines": "all",
120+
"matched": "100%",
121+
"oss_lines": "all",
122+
"purl": [
123+
"pkg:github/scanoss/wfp"
124+
],
125+
"release_date": "2020-07-12",
126+
"server": {
127+
"kb_version": {
128+
"daily": "24.08.16",
129+
"monthly": "24.07"
130+
},
131+
"version": "5.4.8"
132+
},
133+
"source_hash": "0fe279946d388ef07d9c3f6e3ffb8ebe",
134+
"status": "pending",
135+
"url": "https://github.com/scanoss/wfp",
136+
"url_hash": "9b36f30d422d7f77854f298f63c55256",
137+
"url_stats": {},
138+
"vendor": "scanoss",
139+
"version": "6afc1f6"
140+
}
141+
],
142+
"src/json.c": [
143+
{
144+
"component": "scanner.c",
145+
"file": "scanner.c-1.3.3/external/src/json.c",
146+
"file_hash": "8e4d433c1547b59681379e9fe9960546",
147+
"file_url": "https://api.osskb.org/file_contents/8e4d433c1547b59681379e9fe9960546",
148+
"id": "file",
149+
"latest": "1.3.4",
150+
"licenses": [],
151+
"lines": "all",
152+
"matched": "100%",
153+
"oss_lines": "all",
154+
"purl": [
155+
"pkg:github/scanoss/scanner.c"
156+
],
157+
"release_date": "2021-05-26",
158+
"server": {
159+
"kb_version": {
160+
"daily": "24.08.16",
161+
"monthly": "24.07"
162+
},
163+
"version": "5.4.8"
164+
},
165+
"source_hash": "8e4d433c1547b59681379e9fe9960546",
166+
"status": "pending",
167+
"url": "https://github.com/scanoss/scanner.c",
168+
"url_hash": "2d1700ba496453d779d4987255feb5f2",
169+
"url_stats": {},
170+
"vendor": "scanoss",
171+
"version": "1.3.3"
172+
}
173+
],
174+
"src/log.c": [
175+
{
176+
"component": "scanner.c",
177+
"file": "scanner.c-1.3.3/external/src/log.c",
178+
"file_hash": "f00c8a010806ff1593b15c7cbff7e594",
179+
"file_url": "https://api.osskb.org/file_contents/f00c8a010806ff1593b15c7cbff7e594",
180+
"id": "file",
181+
"latest": "1.3.4",
182+
"licenses": [],
183+
"lines": "all",
184+
"matched": "100%",
185+
"oss_lines": "all",
186+
"purl": [
187+
"pkg:github/scanoss/scanner.c"
188+
],
189+
"release_date": "2021-05-26",
190+
"server": {
191+
"kb_version": {
192+
"daily": "24.08.16",
193+
"monthly": "24.07"
194+
},
195+
"version": "5.4.8"
196+
},
197+
"source_hash": "f00c8a010806ff1593b15c7cbff7e594",
198+
"status": "pending",
199+
"url": "https://github.com/scanoss/scanner.c",
200+
"url_hash": "2d1700ba496453d779d4987255feb5f2",
201+
"url_stats": {},
202+
"vendor": "scanoss",
203+
"version": "1.3.3"
204+
}
205+
],
206+
"src/winnowing.c": [
207+
{
208+
"component": "engine",
209+
"file": "external/src/winnowing.c",
210+
"file_hash": "b298d620599a6ad04e2613dfdc9d3f7b",
211+
"file_url": "https://api.osskb.org/file_contents/b298d620599a6ad04e2613dfdc9d3f7b",
212+
"id": "snippet",
213+
"latest": "4.3.4",
214+
"licenses": [],
215+
"lines": "32-161",
216+
"matched": "80%",
217+
"oss_lines": "29-158",
218+
"purl": [
219+
"pkg:github/scanoss/engine"
220+
],
221+
"release_date": "2020-12-30",
222+
"server": {
223+
"kb_version": {
224+
"daily": "24.08.16",
225+
"monthly": "24.07"
226+
},
227+
"version": "5.4.8"
228+
},
229+
"source_hash": "af368f0dfee072472cf57f0694975b28",
230+
"status": "pending",
231+
"url": "https://github.com/scanoss/engine",
232+
"url_hash": "0c0c7aaf65ab9e2e10562d188ff3e511",
233+
"url_stats": {},
234+
"vendor": "scanoss",
235+
"version": "4.0.4"
236+
}
237+
]
238+
}

0 commit comments

Comments
 (0)