npq 3.8.1 → 3.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/npq.mov +0 -0
- package/.github/npq.mp4 +0 -0
- package/.github/npq.png +0 -0
- package/.github/workflows/main.yml +2 -2
- package/README.md +18 -9
- package/__tests__/__fixtures__/test.marshall.js +5 -6
- package/__tests__/cli.test.js +110 -0
- package/__tests__/cliPrompt.test.js +409 -0
- package/__tests__/marshalls.base.test.js +1 -1
- package/__tests__/marshalls.classMethods.test.js +11 -14
- package/__tests__/marshalls.expiredDomains.test.js +2 -2
- package/__tests__/marshalls.provenance.test.js +181 -4
- package/__tests__/marshalls.signatures.test.js +0 -4
- package/__tests__/marshalls.snyk.test.js +294 -0
- package/__tests__/marshalls.tasks.test.js +48 -24
- package/__tests__/marshalls.typosquatting.test.js +16 -9
- package/__tests__/reportResults.test.js +772 -0
- package/__tests__/scripts.test.js +2 -2
- package/bin/npq-hero.js +73 -20
- package/bin/npq.js +113 -21
- package/lib/cli.js +140 -24
- package/lib/helpers/cliPrompt.js +97 -0
- package/lib/helpers/cliSpinner.js +104 -0
- package/lib/helpers/cliSupportHandler.js +50 -7
- package/lib/helpers/packageRepoUtils.js +5 -0
- package/lib/helpers/promiseThrottler.js +96 -0
- package/lib/helpers/reportResults.js +304 -0
- package/lib/helpers/sourcePackages.js +36 -0
- package/lib/marshall.js +42 -65
- package/lib/marshalls/age.marshall.js +3 -2
- package/lib/marshalls/author.marshall.js +36 -7
- package/lib/marshalls/baseMarshall.js +9 -17
- package/lib/marshalls/deprecation.marshall.js +43 -0
- package/lib/marshalls/downloads.marshall.js +1 -1
- package/lib/marshalls/expiredDomains.marshall.js +7 -5
- package/lib/marshalls/index.js +110 -80
- package/lib/marshalls/license.marshall.js +1 -1
- package/lib/marshalls/newbin.marshall.js +1 -2
- package/lib/marshalls/provenance.marshall.js +152 -33
- package/lib/marshalls/repo.marshall.js +6 -5
- package/lib/marshalls/scripts.marshall.js +1 -1
- package/lib/marshalls/signatures.marshall.js +26 -2
- package/lib/marshalls/snyk.marshall.js +61 -15
- package/lib/marshalls/typosquatting.marshall.js +8 -5
- package/lib/marshalls/version-maturity.marshall.js +1 -1
- package/package.json +16 -19
- package/scripts/postinstall.js +10 -11
- package/lib/cliCommons.js +0 -80
|
@@ -3,12 +3,13 @@ const TyposquattingMarshall = require('../lib/marshalls/typosquatting.marshall')
|
|
|
3
3
|
describe('Typosquatting Marshall', () => {
|
|
4
4
|
test('should remove duplicate entries from similar packages', async () => {
|
|
5
5
|
const typosquattingMarshall = new TyposquattingMarshall({
|
|
6
|
-
packageRepoUtils:
|
|
6
|
+
packageRepoUtils: {
|
|
7
|
+
isPackageInAllowList: jest.fn(() => {
|
|
8
|
+
return false // Simulate that the package is not in the allow list
|
|
9
|
+
})
|
|
10
|
+
}
|
|
7
11
|
})
|
|
8
12
|
|
|
9
|
-
// Mock the top packages data to include duplicates
|
|
10
|
-
const originalTopPackages = require('../data/top-packages.json')
|
|
11
|
-
|
|
12
13
|
// Create a test package that would match multiple similar packages
|
|
13
14
|
const pkg = {
|
|
14
15
|
packageName: 'ghtml' // This should match 'html' which appears multiple times in the data
|
|
@@ -21,9 +22,7 @@ describe('Typosquatting Marshall', () => {
|
|
|
21
22
|
} catch (error) {
|
|
22
23
|
// Check that the error message doesn't contain duplicate entries
|
|
23
24
|
const errorMessage = error.message
|
|
24
|
-
expect(errorMessage).toContain(
|
|
25
|
-
'Package name could be a typosquatting attempt for popular package(s):'
|
|
26
|
-
)
|
|
25
|
+
expect(errorMessage).toContain('Potential typosquatting with popular package(s):')
|
|
27
26
|
|
|
28
27
|
// Extract the package names from the error message
|
|
29
28
|
const packagesList = errorMessage.split('popular package(s): ')[1]
|
|
@@ -41,7 +40,11 @@ describe('Typosquatting Marshall', () => {
|
|
|
41
40
|
|
|
42
41
|
test('should not report typosquatting for packages in top packages list', async () => {
|
|
43
42
|
const typosquattingMarshall = new TyposquattingMarshall({
|
|
44
|
-
packageRepoUtils:
|
|
43
|
+
packageRepoUtils: {
|
|
44
|
+
isPackageInAllowList: jest.fn(() => {
|
|
45
|
+
return true
|
|
46
|
+
})
|
|
47
|
+
}
|
|
45
48
|
})
|
|
46
49
|
|
|
47
50
|
// Test with a package that exists in the top packages list
|
|
@@ -55,7 +58,11 @@ describe('Typosquatting Marshall', () => {
|
|
|
55
58
|
|
|
56
59
|
test('should not report typosquatting for packages with no similar matches', async () => {
|
|
57
60
|
const typosquattingMarshall = new TyposquattingMarshall({
|
|
58
|
-
packageRepoUtils:
|
|
61
|
+
packageRepoUtils: {
|
|
62
|
+
isPackageInAllowList: jest.fn(() => {
|
|
63
|
+
return false // Simulate that the package is not in the allow list
|
|
64
|
+
})
|
|
65
|
+
}
|
|
59
66
|
})
|
|
60
67
|
|
|
61
68
|
// Test with a package that has no similar matches
|