Skip to content

Commit dfaf15b

Browse files
committed
chore:SP-1022 Refactor on Jira Markdown output
1 parent 6c55a5d commit dfaf15b

File tree

5 files changed

+49
-10
lines changed

5 files changed

+49
-10
lines changed

Diff for: CHANGELOG.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Upcoming changes...
1111

12+
## [1.19.4] - 2025-01-08
13+
### Added
14+
- Refactor on Jira Markdown output on inspect command
15+
1216
## [1.19.3] - 2025-01-07
1317
### Added
14-
- Add Jira Markdown output on inspect command ç
18+
- Add Jira Markdown output on inspect command
1519
- This is useful for calls from integrations (i.e. Jenkins)
1620

1721
## [1.19.2] - 2025-01-06
@@ -435,4 +439,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
435439
[1.19.0]: https://github.com/scanoss/scanoss.py/compare/v1.18.1...v1.19.0
436440
[1.19.1]: https://github.com/scanoss/scanoss.py/compare/v1.19.0...v1.19.1
437441
[1.19.2]: https://github.com/scanoss/scanoss.py/compare/v1.19.1...v1.19.2
438-
[1.19.3]: https://github.com/scanoss/scanoss.py/compare/v1.19.2...v1.19.3
442+
[1.19.3]: https://github.com/scanoss/scanoss.py/compare/v1.19.2...v1.19.3
443+
[1.19.4]: https://github.com/scanoss/scanoss.py/compare/v1.19.3...v1.19.4

Diff for: src/scanoss/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
THE SOFTWARE.
2323
"""
2424

25-
__version__ = "1.19.3"
25+
__version__ = "1.19.4"

Diff for: src/scanoss/inspection/policy_check.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,11 @@ def generate_jira_table(self, headers, rows, centered_columns=None):
289289
self.print_stderr('ERROR: Header are no set')
290290
return None
291291

292-
table_header = '|*' + col_sep.join(headers) + '*|\\n'
292+
table_header = '|*' + col_sep.join(headers) + '*|\n'
293293
table = table_header
294294
for row in rows:
295295
if len(headers) == len(row):
296-
table += '|' + '|'.join(row) + '|\\n'
296+
table += '|' + '|'.join(row) + '|\n'
297297

298298
return table
299299

Diff for: src/scanoss/inspection/undeclared_component.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ def _get_jira_summary(self, components: list) -> str:
8282
if self.sbom_format == 'settings':
8383
json_str = (json.dumps(self._generate_scanoss_file(components), indent=2).replace('\n', '\\n')
8484
.replace('"', '\\"'))
85-
return f'{len(components)} undeclared component(s) were found.\\nAdd the following snippet into your `scanoss.json` file\\n{{code:json}}\\n{json_str}\\n{{code}}\\n'
85+
return f'{len(components)} undeclared component(s) were found.\nAdd the following snippet into your `scanoss.json` file\n{{code:json}}\n{json.dumps(self._generate_scanoss_file(components), indent=2)}\n{{code}}\n'
8686
else:
8787
json_str = (json.dumps(self._generate_scanoss_file(components), indent=2).replace('\n', '\\n')
8888
.replace('"', '\\"'))
89-
return f'{len(components)} undeclared component(s) were found.\\nAdd the following snippet into your `sbom.json` file\\n{{code:json}}\\n{json_str}\\n{{code}}\\n'
89+
return f'{len(components)} undeclared component(s) were found.\nAdd the following snippet into your `sbom.json` file\n{{code:json}}\n{json.dumps(self._generate_scanoss_file(components), indent=2)}\n{{code}}\n'
9090

9191
return f'{len(components)} undeclared component(s) were found.\\n'
9292

Diff for: tests/test_policy_inspect.py

+37-3
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,36 @@ def test_undeclared_policy_jira_markdown_output(self):
340340
status, results = undeclared.run()
341341
details = results['details']
342342
summary = results['summary']
343-
expected_details_output = "|*Component*|*Version*|*License*|\\n|pkg:github/scanoss/scanner.c|1.3.3|BSD-2-Clause - GPL-2.0-only|\\n|pkg:github/scanoss/scanner.c|1.1.4|GPL-2.0-only|\\n|pkg:github/scanoss/wfp|6afc1f6|Zlib - GPL-2.0-only|\\n|pkg:npm/%40electron/rebuild|3.7.0|MIT|\\n|pkg:npm/%40emotion/react|11.13.3|MIT|\\n"
344-
expected_summary_output = r"5 undeclared component(s) were found.\nAdd the following snippet into your `scanoss.json` file\n{code:json}\n{\n \"bom\": {\n \"include\": [\n {\n \"purl\": \"pkg:github/scanoss/scanner.c\"\n },\n {\n \"purl\": \"pkg:github/scanoss/wfp\"\n },\n {\n \"purl\": \"pkg:npm/%40electron/rebuild\"\n },\n {\n \"purl\": \"pkg:npm/%40emotion/react\"\n }\n ]\n }\n}\n{code}\n"
343+
expected_details_output = """|*Component*|*Version*|*License*|
344+
|pkg:github/scanoss/scanner.c|1.3.3|BSD-2-Clause - GPL-2.0-only|
345+
|pkg:github/scanoss/scanner.c|1.1.4|GPL-2.0-only|
346+
|pkg:github/scanoss/wfp|6afc1f6|Zlib - GPL-2.0-only|
347+
|pkg:npm/%40electron/rebuild|3.7.0|MIT|
348+
|pkg:npm/%40emotion/react|11.13.3|MIT|
349+
"""
350+
expected_summary_output = """5 undeclared component(s) were found.
351+
Add the following snippet into your `scanoss.json` file
352+
{code:json}
353+
{
354+
"bom": {
355+
"include": [
356+
{
357+
"purl": "pkg:github/scanoss/scanner.c"
358+
},
359+
{
360+
"purl": "pkg:github/scanoss/wfp"
361+
},
362+
{
363+
"purl": "pkg:npm/%40electron/rebuild"
364+
},
365+
{
366+
"purl": "pkg:npm/%40emotion/react"
367+
}
368+
]
369+
}
370+
}
371+
{code}
372+
"""
345373
self.assertEqual(status, 0)
346374
self.assertEqual(expected_details_output, details)
347375
self.assertEqual(summary, expected_summary_output)
@@ -353,7 +381,13 @@ def test_copyleft_policy_jira_markdown_output(self):
353381
copyleft = Copyleft(filepath=input_file_name, format_type='jira_md')
354382
status, results = copyleft.run()
355383
details = results['details']
356-
expected_details_output = r"|*Component*|*Version*|*License*|*URL*|*Copyleft*|\n|pkg:github/scanoss/scanner.c|1.3.3|GPL-2.0-only|https://spdx.org/licenses/GPL-2.0-only.html|YES|\n|pkg:github/scanoss/scanner.c|1.1.4|GPL-2.0-only|https://spdx.org/licenses/GPL-2.0-only.html|YES|\n|pkg:github/scanoss/engine|5.4.0|GPL-2.0-only|https://spdx.org/licenses/GPL-2.0-only.html|YES|\n|pkg:github/scanoss/wfp|6afc1f6|GPL-2.0-only|https://spdx.org/licenses/GPL-2.0-only.html|YES|\n|pkg:github/scanoss/engine|4.0.4|GPL-2.0-only|https://spdx.org/licenses/GPL-2.0-only.html|YES|\n"
384+
expected_details_output = """|*Component*|*Version*|*License*|*URL*|*Copyleft*|
385+
|pkg:github/scanoss/scanner.c|1.3.3|GPL-2.0-only|https://spdx.org/licenses/GPL-2.0-only.html|YES|
386+
|pkg:github/scanoss/scanner.c|1.1.4|GPL-2.0-only|https://spdx.org/licenses/GPL-2.0-only.html|YES|
387+
|pkg:github/scanoss/engine|5.4.0|GPL-2.0-only|https://spdx.org/licenses/GPL-2.0-only.html|YES|
388+
|pkg:github/scanoss/wfp|6afc1f6|GPL-2.0-only|https://spdx.org/licenses/GPL-2.0-only.html|YES|
389+
|pkg:github/scanoss/engine|4.0.4|GPL-2.0-only|https://spdx.org/licenses/GPL-2.0-only.html|YES|
390+
"""
357391
self.assertEqual(status, 0)
358392
self.assertEqual(expected_details_output, details)
359393

0 commit comments

Comments
 (0)