Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for GitLab SAST #86

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

0xgoto
Copy link
Contributor

@0xgoto 0xgoto commented Jul 10, 2024

This pull request is to add Gitlab SAST parser to Benchmark tool

@davewichers
Copy link
Contributor

@darkspirit510 - Can you review this and let me know if you are OK with me to merge this? Or provide feedback on the PR?

Copy link
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.

Looks good to me, just small details and one cosmetic idea.

assertEquals(CweNumber.PATH_TRAVERSAL, result.get(5).get(0).getCWE());
}

@Test
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you test the test here? What does this test do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually before implementing a logic in the main java file, I was trying it out in the test file. Only when It passes, i add the same logic there. This is an unnecessary test, I'll remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please let me know, if I need to remove this test

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend to remove it, since it's basically just testing the testfile, not the reader.

String className = vulnerability.getJSONObject("location").getString("file");
className = (className.substring(className.lastIndexOf('/') + 1)).split("\\.")[0];

if (className.startsWith(BenchmarkScore.TESTCASENAME)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use Reader#testNumber and pass BenchmarkScore.TESTCASENAME to it? So instead of

String className = vulnerability.getJSONObject("location").getString("file");
className = (className.substring(className.lastIndexOf('/') + 1)).split("\\.")[0];

if (className.startsWith(BenchmarkScore.TESTCASENAME)) {
[...]
tcr.setNumber(testNumber(className));

Directly check for the test number:

int testNumber = testNumber(vulnerability.getJSONObject("location").getString("file"));

if(testNumber > -1) {
[...]
tcr.setNumber(testNumber);

Just an idea to reduce the amount of code. Disclaimer: Untested, just an idea 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, Modified it and it is working

Copy link
Contributor

Choose a reason for hiding this comment

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

Great, thank you!

@0xgoto
Copy link
Contributor Author

0xgoto commented Jul 11, 2024

Hey @darkspirit510 @davewichers, I found that the results are not properly reflected in the scoreboard. I mean, the report contains a finding, but the scoreboard says that it is not present. I found the same with snyk report also. Can you please, explain me on what basis are these being checked.

@darkspirit510
Copy link
Contributor

Did you debug the file and see if it the reader successfully reads the line/result you mentioned? Benchmark compares results to the expected results file (true/false positive and negative). Some results can be parsed, but the CWE number of a tool might be more specific than the one Benchmark is expecting. That's why some Readers map one CWE number to another. You already do this for CWE 327 in your Reader).

If there's still an issue, I can have a look on the result file, but I'm on vacation, so this has to wait until next weekend 😉

@davewichers
Copy link
Contributor

@darkspirit510 - This has been sitting out there for a month+. Can you look at it when you get a chance?

@darkspirit510
Copy link
Contributor

@davewichers The code itself looks fine to me, but according to @0xgoto's last comment, he expected some different results. To verify, I'd have to create a result file myself (or 0xgoto would have to provide one).

@davewichers
Copy link
Contributor

@0xgoto - can you provide @darkspirit510 with a results file, or better yet provide him instructions on how he can generate one himself?

@davewichers
Copy link
Contributor

@0xgoto - This has been dormant for 5+ months. Are you going to continue to work on this to get it working properly?

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