npq 3.23.0 → 3.23.2
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.
|
@@ -15,6 +15,19 @@ const dns = new Resolver()
|
|
|
15
15
|
dns.setServers(['1.1.1.1', '8.8.8.8'])
|
|
16
16
|
const MARSHALL_NAME = 'maintainers_expired_emails'
|
|
17
17
|
|
|
18
|
+
function stripTerminalControlCharacters(value) {
|
|
19
|
+
if (typeof value !== 'string') {
|
|
20
|
+
return ''
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return [...value]
|
|
24
|
+
.filter((character) => {
|
|
25
|
+
const codePoint = character.codePointAt(0)
|
|
26
|
+
return codePoint >= 0x20 && (codePoint < 0x7f || codePoint > 0x9f)
|
|
27
|
+
})
|
|
28
|
+
.join('')
|
|
29
|
+
}
|
|
30
|
+
|
|
18
31
|
class Marshall extends BaseMarshall {
|
|
19
32
|
constructor(options) {
|
|
20
33
|
super(options)
|
|
@@ -30,16 +43,21 @@ class Marshall extends BaseMarshall {
|
|
|
30
43
|
|
|
31
44
|
async validate(pkg) {
|
|
32
45
|
const data = await this.packageRepoUtils.getPackageInfo(pkg.packageName)
|
|
33
|
-
const
|
|
34
|
-
|
|
46
|
+
const packageVersion = await this.resolvePackageVersion(
|
|
47
|
+
pkg.packageName,
|
|
48
|
+
pkg.packageVersion || 'latest',
|
|
49
|
+
data
|
|
50
|
+
)
|
|
51
|
+
const versionData = packageVersion && data.versions && data.versions[packageVersion]
|
|
35
52
|
|
|
36
|
-
const maintainersAccounts =
|
|
53
|
+
const maintainersAccounts = versionData && versionData.maintainers
|
|
37
54
|
|
|
38
55
|
if (!Array.isArray(maintainersAccounts) || maintainersAccounts.length === 0) {
|
|
39
56
|
throw new NotEvaluated('no maintainers information available for the package')
|
|
40
57
|
}
|
|
41
58
|
|
|
42
59
|
const emailDomains = new Map()
|
|
60
|
+
const maintainersByDomain = new Map()
|
|
43
61
|
let invalidMaintainers = 0
|
|
44
62
|
for (const maintainerInfo of maintainersAccounts) {
|
|
45
63
|
const emailDomain = normalizeMaintainerDomain(maintainerInfo && maintainerInfo.email)
|
|
@@ -50,6 +68,9 @@ class Marshall extends BaseMarshall {
|
|
|
50
68
|
}
|
|
51
69
|
|
|
52
70
|
emailDomains.set(emailDomain, (emailDomains.get(emailDomain) || 0) + 1)
|
|
71
|
+
const domainMaintainers = maintainersByDomain.get(emailDomain) || []
|
|
72
|
+
domainMaintainers.push(maintainerInfo)
|
|
73
|
+
maintainersByDomain.set(emailDomain, domainMaintainers)
|
|
53
74
|
}
|
|
54
75
|
|
|
55
76
|
if (emailDomains.size === 0) {
|
|
@@ -138,10 +159,26 @@ class Marshall extends BaseMarshall {
|
|
|
138
159
|
const domainNoun = corroboratedDomains.length === 1 ? 'domain' : 'domains'
|
|
139
160
|
const resolveVerb = corroboratedDomains.length === 1 ? 'does' : 'do'
|
|
140
161
|
let message = `Maintainer ${domainNoun} ${corroboratedDomains.join(', ')} ${resolveVerb} not resolve in public DNS, and RDAP found no active registration; account takeover may be possible.`
|
|
162
|
+
const affectedMaintainers = corroboratedDomains
|
|
163
|
+
.map((domain) => {
|
|
164
|
+
const identities = maintainersByDomain
|
|
165
|
+
.get(domain)
|
|
166
|
+
.map((maintainer) => {
|
|
167
|
+
const name = stripTerminalControlCharacters(maintainer.name).trim()
|
|
168
|
+
const email = stripTerminalControlCharacters(maintainer.email)
|
|
169
|
+
return name.length > 0 ? `${name} <${email}>` : email
|
|
170
|
+
})
|
|
171
|
+
.join(', ')
|
|
172
|
+
|
|
173
|
+
return `- ${domain}: ${identities}`
|
|
174
|
+
})
|
|
175
|
+
.join('\n')
|
|
176
|
+
|
|
177
|
+
message += `\n\nAffected maintainers:\n${affectedMaintainers}`
|
|
141
178
|
|
|
142
179
|
if (incompleteCount > 0) {
|
|
143
180
|
const recordNoun = incompleteCount === 1 ? 'record' : 'records'
|
|
144
|
-
message +=
|
|
181
|
+
message += `\n\n${incompleteCount} other maintainer ${recordNoun} could not be evaluated.`
|
|
145
182
|
}
|
|
146
183
|
|
|
147
184
|
throw new Warning(message)
|