Skip to content

Add Cognium SARIF reader#285

Open
coggiyadmin wants to merge 5 commits intoOWASP-Benchmark:mainfrom
coggiyadmin:add-cognium-reader
Open

Add Cognium SARIF reader#285
coggiyadmin wants to merge 5 commits intoOWASP-Benchmark:mainfrom
coggiyadmin:add-cognium-reader

Conversation

@coggiyadmin
Copy link
Copy Markdown

Adds scorecard support for Cognium (https://github.com/cogniumhq/cognium),
an open-source SAST tool. No new output format needed — Cognium's existing
--format sarif output is consumed directly.

Generate results:
cognium scan BenchmarkJava/src/ --format sarif --output Cognium.sarif

Changes:

  • parsers/sarif/CogniumReader.java — extends SarifReader with
    CweSourceType.CUSTOM; static ruleId→CWE map for 13 security sink types;
    non-security findings skipped by base class
  • CogniumReaderTest.java + Benchmark_Cognium.sarif test fixture
  • Reader.java — registered in allReaders()

Asok Shanmugam and others added 2 commits April 10, 2026 16:05
Adds CogniumReader, its unit test, and a two-row test fixture for the
Cognium SAST tool (https://cognium.dev / https://github.com/cogniumhq/cognium).

Cognium emits results via:
  cognium scan <path> --format owasp-benchmark --output results.csv

The CSV format uses a single comment/header line followed by one row per
positive detection:
  # test name,category,CWE,real vulnerability
  BenchmarkTest00001,cmdi,78,true

CogniumReader reads the CWE directly from column 2, so no category-to-CWE
lookup table is needed. The reader is registered in Reader.allReaders()
and verified by CogniumReaderTest.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the earlier CSV-based approach with a proper SARIF reader.
Cognium already outputs standard SARIF via --format sarif, so no new
output format is needed in the tool itself.

CogniumReader extends SarifReader with CweSourceType.CUSTOM, providing a
static ruleId-to-CWE mapping for the 13 security sink types Cognium
detects. Non-security findings (reliability, performance, etc.) have no
mapping entry and are silently skipped by the base class.

To generate results:
  cognium scan BenchmarkJava/src/ --format sarif --output Cognium.sarif

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@davewichers
Copy link
Copy Markdown
Contributor

@darkspirit510 - Can you review this when you get a chance and add a run script per these instructions to BenchmarkJava itself?

Copy link
Copy Markdown
Contributor

@darkspirit510 darkspirit510 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davewichers looks good to me, just cosmetical comments 👍

@coggiyadmin
Copy link
Copy Markdown
Author

@davewichers can we merge this one?

coggiyadmin and others added 2 commits April 21, 2026 20:42
Remove the command example (to be replaced by a BenchmarkJava script)
and the verbose properties.cwe description (code is self-explanatory).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@darkspirit510
Copy link
Copy Markdown
Contributor

darkspirit510 commented Apr 24, 2026

@coggiyadmin I used your script at OWASP-Benchmark/BenchmarkJava#453 and got the following warnings.

Analyzing results from Benchmark_1.2-cognium-v1.6.9.sarif
WARNING: No CWE mapping found for ruleID: code_injection
[...]
WARNING: No CWE mapping found for ruleID: external_taint_escape
[...]

Please add those to your mapping table. And since you have to edit it (would not have asked if there were no new mappings) please move the creation of the map to the constructor so it only happens once and not on every CWE lookup. I know, other readers do this, too. Let's be the first to clean up :-)

- Add code_injection (CWE-94) and external_taint_escape (CWE-918/SSRF)
  mappings that were missing and triggered runtime warnings
- Move HashMap construction from customRuleCweMappings() into the
  constructor so the map is built once, not on every CWE lookup
- Add CweNumber.CODE_INJECTION = 94 constant

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Author

@coggiyadmin coggiyadmin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added changes as per the feedback @darkspirit510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants