@axeptio/privacy-score
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -1,3 +0,3 @@ | ||
import calculateScore from "./src/score.js"; | ||
import { calculateScore } from './src/score.js' | ||
console.info(calculateScore(process.argv[2])); | ||
console.info(calculateScore(process.argv[2])) |
{ | ||
"name": "@axeptio/privacy-score", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "This repository hosts a flexible rating algorithm designed for accurate rating and ranking based on specified criteria, used on some of our products", | ||
@@ -13,2 +13,8 @@ "type": "module", | ||
}, | ||
"jest": { | ||
"testEnvironment": "node", | ||
"transform": { | ||
"^.+\\.js$": "babel-jest" | ||
} | ||
}, | ||
"author": "", | ||
@@ -21,2 +27,5 @@ "license": "BSD 3-Clause License", | ||
"devDependencies": { | ||
"@babel/core": "^7.24.0", | ||
"@babel/preset-env": "^7.24.0", | ||
"babel-jest": "^29.7.0", | ||
"eslint": "^8.57.0", | ||
@@ -23,0 +32,0 @@ "jest": "^29.7.0", |
@@ -0,1 +1,2 @@ | ||
import { BlackBox } from './blackbox.js' | ||
import { | ||
@@ -6,4 +7,6 @@ calculateScore, | ||
calculateVendorChoices, | ||
calculateWebsiteSecurity | ||
} from './score.js'; | ||
calculateWebsiteSecurity, | ||
} from './score.js' | ||
import { findVendorOfficial } from './utils.js' | ||
import { BEHAVIORS } from './constants.js' | ||
@@ -18,8 +21,8 @@ describe('src/scripts/analyse/score.js', () => { | ||
fines: null, | ||
pwnd: null | ||
} | ||
}; | ||
pwnd: null, | ||
}, | ||
} | ||
expect(calculateScore(scoreData)).toBe(100); | ||
}); | ||
expect(calculateScore(scoreData)).toBe(100) | ||
}) | ||
@@ -32,9 +35,9 @@ it('should return 80 when RGPD fine is applicable', () => { | ||
fines: { total: 1 }, | ||
pwnd: null | ||
} | ||
}; | ||
pwnd: null, | ||
}, | ||
} | ||
expect(calculateScore(scoreData)).toBe(80); | ||
}); | ||
}); | ||
expect(calculateScore(scoreData)).toBe(80) | ||
}) | ||
}) | ||
@@ -44,14 +47,14 @@ describe('calculateRGPDFine()', () => { | ||
const scoreData = { | ||
total: 1 | ||
}; | ||
total: 1, | ||
} | ||
expect(calculateRGPDFine(scoreData)).toBe(20); | ||
}); | ||
expect(calculateRGPDFine(scoreData)).toBe(20) | ||
}) | ||
it('should return 0 when gdprFine is false', () => { | ||
const scoreData = {}; | ||
const scoreData = {} | ||
expect(calculateRGPDFine(scoreData)).toBe(0); | ||
}); | ||
}); | ||
expect(calculateRGPDFine(scoreData)).toBe(0) | ||
}) | ||
}) | ||
@@ -63,7 +66,7 @@ describe('calculateWebsiteSecurity()', () => { | ||
googleWebRiskData: {}, | ||
googleSafeBrowserData: {} | ||
}; | ||
googleSafeBrowserData: {}, | ||
} | ||
expect(calculateWebsiteSecurity(scoreData)).toBe(0); | ||
}); | ||
expect(calculateWebsiteSecurity(scoreData)).toBe(0) | ||
}) | ||
@@ -74,7 +77,7 @@ it('should return 20 when one website security is breached', () => { | ||
googleWebRiskData: {}, | ||
googleSafeBrowserData: {} | ||
}; | ||
googleSafeBrowserData: {}, | ||
} | ||
expect(calculateWebsiteSecurity(scoreData)).toBe(20); | ||
}); | ||
expect(calculateWebsiteSecurity(scoreData)).toBe(20) | ||
}) | ||
@@ -85,7 +88,7 @@ it('should return 40 when two website security is breached', () => { | ||
googleWebRiskData: { threat: true }, | ||
googleSafeBrowserData: {} | ||
}; | ||
googleSafeBrowserData: {}, | ||
} | ||
expect(calculateWebsiteSecurity(scoreData)).toBe(40); | ||
}); | ||
expect(calculateWebsiteSecurity(scoreData)).toBe(40) | ||
}) | ||
@@ -96,43 +99,43 @@ it('should return 60 when all website security is breached', () => { | ||
googleWebRiskData: { threat: true }, | ||
googleSafeBrowserData: { matches: true } | ||
}; | ||
googleSafeBrowserData: { matches: true }, | ||
} | ||
expect(calculateWebsiteSecurity(scoreData)).toBe(60); | ||
}); | ||
}); | ||
expect(calculateWebsiteSecurity(scoreData)).toBe(60) | ||
}) | ||
}) | ||
describe('calculateDataMinimization()', () => { | ||
it('should return 0 when knownVendors length is less than 20', () => { | ||
expect(calculateDataMinimization(19)).toBe(0); | ||
}); | ||
expect(calculateDataMinimization(19)).toBe(0) | ||
}) | ||
it('should return 10 when knownVendors length is greater than 20', () => { | ||
expect(calculateDataMinimization(20)).toBe(10); | ||
}); | ||
expect(calculateDataMinimization(20)).toBe(10) | ||
}) | ||
it('should return 20 when knownVendors length is greater than 100', () => { | ||
expect(calculateDataMinimization(100)).toBe(20); | ||
}); | ||
expect(calculateDataMinimization(100)).toBe(20) | ||
}) | ||
it('should return 20 + 0,05 of vendors when knownVendors length is greater than 101 (test 250', () => { | ||
expect(calculateDataMinimization(250)).toBe(33); | ||
}); | ||
expect(calculateDataMinimization(250)).toBe(33) | ||
}) | ||
it('should return 20 + 0,05 of vendors when knownVendors length is greater than 101 (test 300)', () => { | ||
expect(calculateDataMinimization(300)).toBe(35); | ||
}); | ||
}); | ||
expect(calculateDataMinimization(300)).toBe(35) | ||
}) | ||
}) | ||
describe('calculateVendorChoices()', () => { | ||
it('should return 0 when all vendors have a score greater than 70', () => { | ||
const knownVendors = [{ score: 71 }, { score: 80 }, { score: 90 }]; | ||
const knownVendors = [{ score: 71 }, { score: 80 }, { score: 90 }] | ||
expect(calculateVendorChoices(knownVendors)).toBe(0); | ||
}); | ||
expect(calculateVendorChoices(knownVendors)).toBe(0) | ||
}) | ||
it('should return 5 when more than 30% of vendors have a score less than 70', () => { | ||
const knownVendors = [{ score: 60 }, { score: 80 }, { score: 90 }]; | ||
const knownVendors = [{ score: 60 }, { score: 80 }, { score: 90 }] | ||
expect(calculateVendorChoices(knownVendors)).toBe(5); | ||
}); | ||
expect(calculateVendorChoices(knownVendors)).toBe(5) | ||
}) | ||
@@ -145,7 +148,7 @@ it('should return 10 when more than 50% and less then 70% of vendors have a score less than 70', () => { | ||
{ score: 80 }, | ||
{ score: 80 } | ||
]; | ||
{ score: 80 }, | ||
] | ||
expect(calculateVendorChoices(knownVendors)).toBe(10); | ||
}); | ||
expect(calculateVendorChoices(knownVendors)).toBe(10) | ||
}) | ||
@@ -160,8 +163,84 @@ it('should return 15 when more than 85% of vendors have a score less than 70', () => { | ||
{ score: 60 }, | ||
{ score: 80 } | ||
]; | ||
{ score: 80 }, | ||
] | ||
expect(calculateVendorChoices(knownVendors)).toBe(15); | ||
}); | ||
}); | ||
}); | ||
expect(calculateVendorChoices(knownVendors)).toBe(15) | ||
}) | ||
}) | ||
describe('BlackBox', () => { | ||
const vendorsDictionary = [ | ||
{ name: 'axeptio', score: 100 }, | ||
{ name: 'didomi', score: 30 }, | ||
] | ||
const blackbox = new BlackBox(vendorsDictionary, 100) | ||
const vendor = { name: 'axeptio' } | ||
it('blackbox.findScoreOfVendor()', () => { | ||
expect(blackbox.findScoreOfVendor(vendor)).toEqual( | ||
findVendorOfficial(vendor, vendorsDictionary) | ||
) | ||
}) | ||
it('blackbox.findVendorOfficial()', () => { | ||
expect(blackbox.findVendorOfficial(vendor, vendorsDictionary)).toEqual( | ||
findVendorOfficial(vendor, vendorsDictionary) | ||
) | ||
}) | ||
it('blackbox.calculateScore()', () => { | ||
const scoreData = { | ||
vendors: [], | ||
knownVendors: [], | ||
webservices: { | ||
fines: null, | ||
pwnd: null, | ||
}, | ||
} | ||
expect(blackbox.calculateScore(scoreData)).toBe(100) | ||
}) | ||
it('blackbox.calculateScore() 100 vendors', () => { | ||
const scoreData = { | ||
vendors: new Array(200).fill({ name: 'didomi' }), | ||
knownVendors: [], | ||
webservices: { | ||
fines: null, | ||
pwnd: null, | ||
}, | ||
} | ||
expect(blackbox.calculateScore(scoreData)).toBe(70) | ||
}) | ||
it('blackbox.auditWebsite() aceptable', () => { | ||
const _blackbox = new BlackBox(vendorsDictionary, { companyRating: 80 }) | ||
expect(_blackbox.auditWebsite()).toBe(BEHAVIORS.ACCEPTABLE) | ||
}) | ||
it('blackbox.auditWebsite() rejectable', () => { | ||
const _blackbox = new BlackBox(vendorsDictionary, { companyRating: 50 }) | ||
expect(_blackbox.auditWebsite()).toBe(BEHAVIORS.REJECTABLE) | ||
}) | ||
it('blackbox.auditVendor() allowed', () => { | ||
const _blackbox = new BlackBox(vendorsDictionary, { companyRating: 100 }) | ||
expect(_blackbox.auditVendor({ name: 'axeptio' })).toEqual({ | ||
allowed: true, | ||
denied: false, | ||
name: 'axeptio', | ||
}) | ||
}) | ||
it('blackbox.auditVendor() denied', () => { | ||
const _blackbox = new BlackBox(vendorsDictionary, { companyRating: 20 }) | ||
expect(_blackbox.auditVendor({ name: 'unknown', iabId: -42 })).toEqual({ | ||
allowed: false, | ||
denied: true, | ||
name: 'unknown', | ||
iabId: -42, | ||
}) | ||
}) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18247
412
6