From 25d7bba73077fcd3bda39ab73c9d7b74e3c4ee92 Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Sun, 11 Feb 2024 20:30:56 +0100 Subject: [PATCH 1/7] fix clair docs according to PR #9355 --- docs/content/en/integrations/parsers/file/clair.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/en/integrations/parsers/file/clair.md b/docs/content/en/integrations/parsers/file/clair.md index 235f801ee94..704003ba0ae 100644 --- a/docs/content/en/integrations/parsers/file/clair.md +++ b/docs/content/en/integrations/parsers/file/clair.md @@ -2,7 +2,7 @@ title: "Clair Scan" toc_hide: true --- -Import JSON reports of Docker image vulnerabilities. +Import JSON reports of Docker image vulnerabilities Clair Scan or the Clair Klar Client. ### Sample Scan Data Sample Clair Scan scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/clair). \ No newline at end of file From 99fd00925705332603bf7b0ed532e0d5e7a34a07 Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Sun, 11 Feb 2024 20:31:57 +0100 Subject: [PATCH 2/7] remove clair_klar --- docs/content/en/integrations/parsers/file/clair_klar.md | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 docs/content/en/integrations/parsers/file/clair_klar.md diff --git a/docs/content/en/integrations/parsers/file/clair_klar.md b/docs/content/en/integrations/parsers/file/clair_klar.md deleted file mode 100644 index 05651bf267c..00000000000 --- a/docs/content/en/integrations/parsers/file/clair_klar.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: "Clair Klar Scan" -toc_hide: true ---- -Import JSON reports of Docker image vulnerabilities from clair klar -client. - -### Sample Scan Data -Sample Clair Klar Scan scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/clair_klar). \ No newline at end of file From a374f690ec69a44f46441bd50a26d5a05c40a91d Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Sun, 11 Feb 2024 20:33:23 +0100 Subject: [PATCH 3/7] update --- docs/content/en/integrations/parsers/file/clair.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/en/integrations/parsers/file/clair.md b/docs/content/en/integrations/parsers/file/clair.md index 704003ba0ae..7c7ac5baefc 100644 --- a/docs/content/en/integrations/parsers/file/clair.md +++ b/docs/content/en/integrations/parsers/file/clair.md @@ -2,7 +2,7 @@ title: "Clair Scan" toc_hide: true --- -Import JSON reports of Docker image vulnerabilities Clair Scan or the Clair Klar Client. +You can import JSON reports of Docker image vulnerabilities found by a Clair scan or the Clair Klar client. ### Sample Scan Data Sample Clair Scan scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/clair). \ No newline at end of file From fcfad64b2412a6750d4ad7ecea685cc968090e73 Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Sun, 11 Feb 2024 20:53:07 +0100 Subject: [PATCH 4/7] start to implement unittest to test if a parser exists for a md file --- docs/content/en/integrations/parsers/file/asfd.md | 9 +++++++++ unittests/test_parsers.py | 5 +++++ 2 files changed, 14 insertions(+) create mode 100644 docs/content/en/integrations/parsers/file/asfd.md diff --git a/docs/content/en/integrations/parsers/file/asfd.md b/docs/content/en/integrations/parsers/file/asfd.md new file mode 100644 index 00000000000..7403ac88575 --- /dev/null +++ b/docs/content/en/integrations/parsers/file/asfd.md @@ -0,0 +1,9 @@ +--- +title: "asdf" +toc_hide: true +--- + +adsf + +### Sample Scan Data +Sample AWS Security Finding Format (ASFF) scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/asdf). \ No newline at end of file diff --git a/unittests/test_parsers.py b/unittests/test_parsers.py index 9832b7f2b3e..02797b618fc 100644 --- a/unittests/test_parsers.py +++ b/unittests/test_parsers.py @@ -93,3 +93,8 @@ def test_file_existence(self): if ".read()" in str(line): read_true = True i = 0 + + def test_parser_existence(self): + for docs in os.scandir(os.path.join(basedir, 'docs', 'content', 'en', 'integrations', 'parsers', 'file')): + print(docs) + \ No newline at end of file From 2f76adedc8733c498dac58910978d00b265bb92b Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Sun, 11 Feb 2024 21:03:08 +0100 Subject: [PATCH 5/7] unittest to test if parser exists to a documented parser --- unittests/test_parsers.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/unittests/test_parsers.py b/unittests/test_parsers.py index 02797b618fc..a0eb9d8f44d 100644 --- a/unittests/test_parsers.py +++ b/unittests/test_parsers.py @@ -96,5 +96,12 @@ def test_file_existence(self): def test_parser_existence(self): for docs in os.scandir(os.path.join(basedir, 'docs', 'content', 'en', 'integrations', 'parsers', 'file')): - print(docs) - \ No newline at end of file + if docs.name not in [ + '_index.md', + ]: + with self.subTest(parser=docs.name.split('.md')[0], category='parser'): + parser = os.path.join(basedir, 'dojo', 'tools', f"{docs.name.split('.md')[0]}", "parser.py") + self.assertTrue( + os.path.isfile(parser), + f"Parser '{parser}' is missing or using different name" + ) From 011433f3dbec2888eff0981d55d5b12887054212 Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Sun, 11 Feb 2024 21:05:16 +0100 Subject: [PATCH 6/7] add edgescan and codeql to skip this test --- unittests/test_parsers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittests/test_parsers.py b/unittests/test_parsers.py index a0eb9d8f44d..ac2b75730c0 100644 --- a/unittests/test_parsers.py +++ b/unittests/test_parsers.py @@ -97,7 +97,7 @@ def test_file_existence(self): def test_parser_existence(self): for docs in os.scandir(os.path.join(basedir, 'docs', 'content', 'en', 'integrations', 'parsers', 'file')): if docs.name not in [ - '_index.md', + '_index.md', 'codeql.md', 'edgescan.md' ]: with self.subTest(parser=docs.name.split('.md')[0], category='parser'): parser = os.path.join(basedir, 'dojo', 'tools', f"{docs.name.split('.md')[0]}", "parser.py") From 2fb3dfc3ab7ecfc71ff3f8a84d3beefef84cdd7a Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Sun, 11 Feb 2024 21:21:02 +0100 Subject: [PATCH 7/7] :tada: works fine, removed asfd --- docs/content/en/integrations/parsers/file/asfd.md | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 docs/content/en/integrations/parsers/file/asfd.md diff --git a/docs/content/en/integrations/parsers/file/asfd.md b/docs/content/en/integrations/parsers/file/asfd.md deleted file mode 100644 index 7403ac88575..00000000000 --- a/docs/content/en/integrations/parsers/file/asfd.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: "asdf" -toc_hide: true ---- - -adsf - -### Sample Scan Data -Sample AWS Security Finding Format (ASFF) scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/asdf). \ No newline at end of file