Skip to content

Commit

Permalink
Fixed weird encoding (#25)
Browse files Browse the repository at this point in the history
* fix: added encoding to write

* chore: updated dependencies
  • Loading branch information
KittyChiu authored Jul 1, 2024
1 parent ae5d189 commit 74b2eb8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
6 changes: 4 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function run() {

// Extract risks from OWASP Top 10 data
const risks = owasp10.getOwasp10(owaspDir, indexFile)
fs.writeFileSync(risksFile, JSON.stringify(risks))
fs.writeFileSync(risksFile, JSON.stringify(risks), { encoding: 'utf8' })
if (!fs.existsSync(risksFile)) {
throw new Error(`File ${risksFile} does not exist.`)
}
Expand Down
4 changes: 3 additions & 1 deletion src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ const fs = require('fs')
// Function to map risks to alerts
function mapRisksToAlerts(owasp10Path, alertsPath, csvOutputPath) {
// Create a CSV file and write the header
fs.writeFileSync(csvOutputPath, 'repo_name,alert_no,risk,cwe_id\n')
fs.writeFileSync(csvOutputPath, 'repo_name,alert_no,risk,cwe_id\n', {
encoding: 'utf8'
})

// Read and parse the data from owasp10Path
const owasp10Data = JSON.parse(fs.readFileSync(owasp10Path, 'utf8'))
Expand Down

0 comments on commit 74b2eb8

Please sign in to comment.