mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 20:59:05 +00:00
Send to zulip
This commit is contained in:
62
aws/lambda-nodejs18.x/UpdateZulipStreams/node_modules/aws-sdk/scripts/region-checker/allowlist.js
generated
vendored
Normal file
62
aws/lambda-nodejs18.x/UpdateZulipStreams/node_modules/aws-sdk/scripts/region-checker/allowlist.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
var allowlist = {
|
||||
'/config.js': [
|
||||
24,
|
||||
25,
|
||||
85,
|
||||
86,
|
||||
207,
|
||||
261,
|
||||
262
|
||||
],
|
||||
'/credentials/cognito_identity_credentials.js': [
|
||||
78,
|
||||
79,
|
||||
109
|
||||
],
|
||||
'/credentials/shared_ini_file_credentials.js': [
|
||||
4,
|
||||
],
|
||||
'/credentials/sso_credentials.js': [
|
||||
15,
|
||||
],
|
||||
'/http.js': [
|
||||
5
|
||||
],
|
||||
'/rds/signer.js': [
|
||||
43,
|
||||
44,
|
||||
97,
|
||||
99,
|
||||
110,
|
||||
112
|
||||
],
|
||||
'/region/utils.js': [
|
||||
10
|
||||
],
|
||||
'/request.js': [
|
||||
318,
|
||||
319
|
||||
],
|
||||
'/services/s3.js': [
|
||||
87,
|
||||
88,
|
||||
260,
|
||||
262,
|
||||
275,
|
||||
281,
|
||||
641,
|
||||
643,
|
||||
762,
|
||||
773,
|
||||
774,
|
||||
775,
|
||||
780
|
||||
],
|
||||
'/token/sso_token_provider.js': [
|
||||
60
|
||||
]
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
allowlist: allowlist
|
||||
};
|
||||
75
aws/lambda-nodejs18.x/UpdateZulipStreams/node_modules/aws-sdk/scripts/region-checker/index.js
generated
vendored
Normal file
75
aws/lambda-nodejs18.x/UpdateZulipStreams/node_modules/aws-sdk/scripts/region-checker/index.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var allowlist = require('./allowlist').allowlist;
|
||||
|
||||
function checkFile(location) {
|
||||
var file = fs.readFileSync(location);
|
||||
var code = file.toString();
|
||||
var lines = code.split('\n');
|
||||
var regionMatches = [];
|
||||
|
||||
lines.forEach(function(line, idx) {
|
||||
var matches = line.match(/(us|eu|ap|sa|ca)-\w+-\d+/g);
|
||||
if (matches) {
|
||||
regionMatches.push({
|
||||
file: location,
|
||||
line: idx,
|
||||
code: line
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return regionMatches;
|
||||
}
|
||||
|
||||
function recursiveGetFilesIn(directory, extensions) {
|
||||
var filenames = [];
|
||||
|
||||
var keys = fs.readdirSync(directory);
|
||||
|
||||
for (var i = 0, iLen = keys.length; i < iLen; i++) {
|
||||
// check if it is a file
|
||||
var keyPath = path.join(directory, keys[i]);
|
||||
var stats = fs.statSync(keyPath);
|
||||
if (stats.isDirectory()) {
|
||||
filenames = filenames.concat(
|
||||
recursiveGetFilesIn(keyPath, extensions)
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (extensions.indexOf(path.extname(keyPath)) >= 0) {
|
||||
filenames.push(path.join(keyPath));
|
||||
}
|
||||
}
|
||||
|
||||
return filenames;
|
||||
}
|
||||
|
||||
function checkForRegions() {
|
||||
var libPath = path.join(__dirname, '..', '..', 'lib');
|
||||
var filePaths = recursiveGetFilesIn(libPath, ['.js']);
|
||||
var regionMatches = [];
|
||||
var warnings = [];
|
||||
|
||||
filePaths.forEach(function(filePath) {
|
||||
regionMatches = regionMatches.concat(checkFile(filePath));
|
||||
});
|
||||
|
||||
regionMatches.forEach(function(match) {
|
||||
var normalizedPath = match.file.substring(libPath.length);
|
||||
if (allowlist[normalizedPath] && allowlist[normalizedPath].indexOf(match.line) >= 0) {
|
||||
return;
|
||||
}
|
||||
warnings.push('File: ' + normalizedPath + '\tLine ' + match.line + ':\t' + match.code.trim());
|
||||
});
|
||||
|
||||
if (warnings.length) {
|
||||
console.error('Hard-coded regions detected. This should only be done if absolutely certain!');
|
||||
warnings.forEach(function(warning) {
|
||||
console.error(warning);
|
||||
});
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
checkForRegions();
|
||||
Reference in New Issue
Block a user