The following Snyk vulnerability is being reported when I run
% snyk code test
Testing /mydir ...
✗ [High] Cross-Site Request Forgery (CSRF)
Path: src/com/xxx/ConfigSecurity.java, line 22
Info: CSRF protection is disabled by disable. This allows the attackers to execute requests on a user's behalf.
✔ Test completed
What I should do to ignore this vulnerability?
I got the vulnerability id running:
% snyk code test --json
And then I could see the vulnerability id in the response:
{
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"version": "2.1.0",
"runs": [
{
"tool": {
"driver": {
"name": "SnykCode",
"semanticVersion": "1.0.0",
"version": "1.0.0",
"rules": [
{
==> "id": "java/DisablesCSRFProtection",
"name": "DisablesCSRFProtection",
...
Then I created a Snyk config file running:
% snyk ignore --id=java/DisablesCSRFProtection
And now the snyk config file contains:
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.25.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
java/DisablesCSRFProtection:
- '*':
reason: None Given
expires: 2022-07-24T11:41:53.787Z
created: 2022-06-24T11:41:53.791Z
patch: {}
However, when I run snyk in the same directory which contains the Snyk config file I created, the same error is reported:
% snyk code test
Testing /Users/sergiostateri/projects/payment-notification-relay ...
✗ [High] Cross-Site Request Forgery (CSRF)
Path: src/main/java/com/xxx/ConfigSecurity.java, line 22
Info: CSRF protection is disabled by disable. This allows the attackers to execute requests on a user's behalf.
✔ Test completed
Organization: customer-retention
Test type: Static code analysis
Project path: /Users/sergiostateri/projects/payment-notification-relay
1 Code issues found
1 [High]
Note, the point of this question isn't Why I want to ignore these vulnerability (I have good reasons), but just how to ignore it.