forcedotcom / sfdx-scanner

MIT License
213 stars 49 forks source link

[Feature Request] PMD reports contain absolute paths #1185

Open bh-sergio-clara opened 1 year ago

bh-sergio-clara commented 1 year ago

Describe the bug Even though PMD provides a mechanism to relativize paths (see --relativize-paths-with in docs) however that's not being passed down by scanner which means that reports will come out referencing files with absolute paths.

We'd like to store the results with our code (to keep track of progress, calculate detas vs. some baseline, for example) and this makes it impossible if you have a team sharing the code or would cause problems if the project changes location.

To Reproduce Steps to reproduce the behavior: sfdx scanner:run --engine=pmd --target=force-app/main/default/classes/SomeClass.cls --pmdconfig=scanner/some-rule-set.xml --format=json

[
  {
    "engine": "pmd-custom",
    "fileName": "/Users/MyUser/MyRepo/force-app/main/default/classes/BadClass.cls",
    "violations": [
      {
        "line": 211,
        "column": 5,
        "endLine": 211,
        "endColumn": 36,
        "severity": 3,
        "ruleName": "ApexCRUDViolation",
        "category": "Security",
        "url": "https://pmd.github.io/pmd-6.55.0/pmd_rules_apex_security.html#apexcrudviolation",
        "message": "\nValidate CRUD permission before SOQL/DML operation or enforce user mode\n"
      }
    ]
  }
]

Expected behavior We'd expect to only see relative paths in the reports. We'd like to be able to either provide the --relativize-paths-with argument or equivalent mechanism where the scanner could itself figure out the root path and pass it down to PMD.

Desktop (please complete the following information):

Additional context

"Workaround": N/A

"Urgency": Kind of "Business stopping". We want to integrate the scanner as part of our workflows but since we have a ton of code already (which has passed security review a few times) we'd like to focus only on new/modified code and we rely on an external mechanism to create and compare reports from a "baseline".

git2gus[bot] commented 1 year ago

This issue has been linked to a new work item: W-14145486

johnbelosf commented 1 year ago

Thank you @bh-sergio-clara we'll discuss internally