chore: only scan for allowed registries in yarn.lock
This commit is contained in:
parent
d382887e67
commit
1dd1da1638
1 changed files with 13 additions and 7 deletions
|
|
@ -1,10 +1,16 @@
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const yarnLockPath = './yarn.lock';
|
const lockFileContent = fs.readFileSync(path.resolve('./yarn.lock'), 'utf8');
|
||||||
const data = fs.readFileSync(path.resolve(yarnLockPath), 'utf8');
|
|
||||||
if (data.match(/artifactory/g)) {
|
const allowedRegistries = ['registry.yarnpkg.com', 'registry.npmjs.org'];
|
||||||
throw new Error(
|
const resolvedUrls = lockFileContent.match(/"https:.*"/g);
|
||||||
'Artifactory references in your yarn.lock! Please make sure you are using a public npm registry when downloading your dependencies!',
|
resolvedUrls.forEach(url => {
|
||||||
);
|
const [, registry] = url.match(/^"https:\/\/(.*?)\/.*"$/) || [];
|
||||||
}
|
if (!allowedRegistries.includes(registry)) {
|
||||||
|
throw new Error(
|
||||||
|
`Disallowed registries ("${registry}") in your yarn.lock!
|
||||||
|
Please make sure you are using a public npm registry when downloading your dependencies!`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue