Skip to content

Commit

Permalink
fix(sarif): no pathToFileURL
Browse files Browse the repository at this point in the history
  • Loading branch information
Bas950 committed Feb 20, 2025
1 parent b7f56a2 commit 15d1464
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/pmd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

jobs:
pmd:
Expand All @@ -30,19 +27,11 @@ jobs:
run: npm ci

- name: Validate metadata and build (changed files)
if: github.event_name == 'push' || github.event_name == 'pull_request'
run: npx pmd build --changed --no-kill --validate --sarif
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true

- name: Validate metadata and build (all files)
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
run: npx pmd build --all --no-kill --validate --sarif
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
Expand Down
8 changes: 4 additions & 4 deletions cli/src/util/sarif.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { writeFile } from 'node:fs/promises'
import { resolve } from 'node:path'
import process from 'node:process'
import { pathToFileURL } from 'node:url'
import { getCliPackageJson } from './getPackageJson.js'

export enum SarifRuleId {
Expand Down Expand Up @@ -107,15 +106,16 @@ export function addSarifLog(log: {
column: number
}
}) {
log.path = log.path.replace(process.cwd(), '')
// Remove the cwd from the path. And remove the leading slash.
log.path = log.path.replace(process.cwd(), '').slice(1)

if (typeof sarifArtifactIndices[log.path] === 'undefined') {
sarifArtifactIndices[log.path] = nextArtifactIndex++

// Create a new entry in the files dictionary.
sarifFiles[log.path] = {
location: {
uri: pathToFileURL(log.path).toString(),
uri: log.path,
},
}
}
Expand All @@ -133,7 +133,7 @@ export function addSarifLog(log: {
{
physicalLocation: {
artifactLocation: {
uri: pathToFileURL(log.path),
uri: log.path,
index: sarifArtifactIndices[log.path],
},
...(log.position && log.position.line > 0
Expand Down

0 comments on commit 15d1464

Please sign in to comment.