Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const filter = (filePath) => {
// The filePath is absolute, but should be relative as micromatch will
// match against the relative path of the routes. Matching against
// an absolute path requires the use of path.join which causes issues on Windows:
// https://github.com/micromatch/micromatch/issues/95
filePath = path.relative(srcPath, filePath)
const fileName = path.parse(filePath).base
const isIgnored = mm.any(filePath, ignoredFiles)
const isJunk = junk.is(fileName)
// Copy file when it's not ignored or not junk
const copy = isIgnored === false && isJunk === false
if (opts.verbose === true) {
if (copy === false) log(`{cyan:Skipping file: {grey:${ filePath }`)
if (copy === true) log(`{cyan:Copying file: {grey:${ filePath }`)
}
// Return true to include, false to exclude
return copy
}
app.post('/invite', json(), (req, res) => {
const { channel, email } = req.body;
const captchaResponse = req.body['g-recaptcha-response'];
let errorMessage = null;
if (channelsFiltered && !channelsFiltered.includes(channel)) {
errorMessage = 'Not a permitted channel';
} else if (channelsFiltered && !slack.getChannelId(channel)) {
errorMessage = `Channel "${channel}" not found`;
} else if (!email) {
errorMessage = 'No email provided';
} else if (recaptcha.secret && (!captchaResponse || !captchaResponse.length)) {
errorMessage = 'Invalid captcha';
} else if (!remail().test(email)) {
errorMessage = 'Invalid email';
} else if (emails && !match.any(email, acceptedEmails)) {
errorMessage = 'Your email is not on the accepted list.';
} else if (coc && Number(req.body.coc) !== 1) {
errorMessage = 'Agreement to CoC is mandatory';
}
if (errorMessage) {
return res.status(400).json({ msg: errorMessage });
}
const captchaData = {
secret: recaptcha.secret,
response: captchaResponse,
remoteip: req.connection.remoteAddress,
};
const captchaCallback = (err) => {
if (err) return res.status(400).send({ msg: err });
function match (p) {
return mm.any(p, ignoredFiles)
}
function ignore(fileMeta, opts) {
if (typeof opts.ignore === 'function') {
return opts.ignore(fileMeta, opts);
}
if (typeof opts.ignore === 'string' || Array.isArray(opts.ignore)) {
return micromatch.any(fileMeta.sourceValue, opts.ignore);
}
return false;
}
return source => !micromatch.any(url.parse(source).hostname, whitelist);
}
filepath &&
allSensitiveDataPatterns &&
allSensitiveDataPatterns.ignoredData &&
globMatching.any(filepath, allSensitiveDataPatterns.ignoredData, {
matchBase: true,
nocase: true,
})
) {
return false;
}
if (
filepath &&
allSensitiveDataPatterns &&
allSensitiveDataPatterns.sensitiveData &&
globMatching.any(filepath, allSensitiveDataPatterns.sensitiveData, {
matchBase: true,
nocase: true,
})
) {
return true;
}
return false;
}
_isNohoist = (info: HoistManifest): boolean => {
if (this._isTopPackage(info)) {
return false;
}
if (info.nohoistList && info.nohoistList.length > 0 && mm.any(this._originalPath(info), info.nohoistList)) {
return true;
}
if (this._config.plugnplayEnabled) {
return true;
}
return false;
};
_isRootPackage = (pkg: Manifest): boolean => {
let res1 = _.filter(tasks, (task) => {
return micromatch.any(host.extract(task), filter.filterText + '*');
});
let res2 = _.filter(tasks, (task) => {
function isSensitiveData(filepath, allSensitiveDataPatterns) {
if (
filepath &&
allSensitiveDataPatterns &&
allSensitiveDataPatterns.ignoredData &&
globMatching.any(filepath, allSensitiveDataPatterns.ignoredData, {
matchBase: true,
nocase: true,
})
) {
return false;
}
if (
filepath &&
allSensitiveDataPatterns &&
allSensitiveDataPatterns.sensitiveData &&
globMatching.any(filepath, allSensitiveDataPatterns.sensitiveData, {
matchBase: true,
nocase: true,
})
) {