-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reapply "Merge pull request #60 from RedHatProductSecurity/feature/ad…
…d-testing" This reverts commit bea2884.
- Loading branch information
1 parent
bea2884
commit f7c34e7
Showing
13 changed files
with
584,917 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Run Tests | ||
on: push | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install modules | ||
run: yarn | ||
- name: Run tests | ||
run: yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea | ||
node_modules/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const { CVSS40 } = require('./cvss40'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const testDataPaths = fs.readdirSync('./data').map(fileName => ({ | ||
path: path.join('./data', fileName), | ||
name: fileName, | ||
})); | ||
|
||
describe('CVSS 4.0', () => { | ||
const testData = testDataPaths.reduce((data, file) => { | ||
const fileData = fs.readFileSync(file.path, 'utf8'); | ||
const lineEntries = fileData.split('\n'); | ||
const scoredVectors = lineEntries.map(vectorScore => { | ||
const vectorScorePair = vectorScore.trim().split(' - '); | ||
return (vectorScorePair.length !== 2) ? null : { vector: vectorScorePair[0], score: parseFloat(vectorScorePair[1]) }; | ||
}).filter(Boolean); | ||
data[file.name] = scoredVectors; | ||
return data; | ||
}, {}); | ||
|
||
Object.entries(testData).forEach(([fileName, vectorScores]) => { | ||
it(`should calculate scores in ${fileName} correctly`, () => { | ||
vectorScores.forEach(({ vector, score }) => { | ||
expect(new CVSS40(vector).score).toBe(score); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.