Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Get document, or throw exception on error
try {
var notificationConfig = yaml.safeLoad(fs.readFileSync('config.yml', 'utf8'));
} catch (e) {
winston.log('error', e);
}
/* Let's instantiate some good things */
var client = new twilio(notificationConfig['credentials']['twilio']['accountSid'], notificationConfig['credentials']['twilio']['authToken']);
AWS.credentials = new AWS.Credentials();
AWS.credentials.accessKeyId = notificationConfig['credentials']['aws']['accessKeyId'];
AWS.credentials.secretAccessKey = notificationConfig['credentials']['aws']['secretAccessKey'];
AWS.config = new AWS.Config();
AWS.config.region = notificationConfig['credentials']['aws']['region'];
var s3 = new AWS.S3();
/* Set up google home */
googlehome.device('Google-Home'); // Change to your Google Home name
/* Config Web */
async function connect() {
let esConfig
let client
// use local client
if (!process.env.ES_HOST) {
client = new elasticsearch.Client({ host: 'localhost:9200' })
} else {
await new Promise((resolve, reject) => AWS.config.getCredentials((err) => {
if (err) return reject(err)
return resolve()
}))
AWS.config.update({
credentials: new AWS.Credentials(process.env.AWS_ACCESS_KEY_ID,
process.env.AWS_SECRET_ACCESS_KEY),
region: process.env.AWS_REGION || 'us-east-1'
})
esConfig = {
hosts: [process.env.ES_HOST],
connectionClass: httpAwsEs,
awsConfig: new AWS.Config({ region: process.env.AWS_REGION || 'us-east-1' }),
httpOptions: {},
// Note that this doesn't abort the query.
requestTimeout: 120000 // milliseconds
}
client = new elasticsearch.Client(esConfig)
}
await new Promise((resolve, reject) => client.ping({ requestTimeout: 1000 },
function _getClients(sourceInfo) {
const { port } = sourceInfo;
const s3sourceCredentials = new AWS.Credentials({
accessKeyId: 'accessKey1',
secretAccessKey: 'verySecretKey1',
});
const backbeatClient = new BackbeatClient({
endpoint: `http://localhost:${port}`,
credentials: s3sourceCredentials,
sslEnabled: false,
maxRetries: 0,
httpOptions: { timeout: 0 },
});
const awsClient = new AWS.S3({
endpoint: 'http://localhost:8000',
credentials: s3sourceCredentials,
sslEnabled: false,
maxRetries: 0,
.subscribe(credential => {
console.log('navbar-dropdown-menu-link.component#ngOnInit: Observable', credential);
AWS.config.update({
credentials: new AWS.Credentials(credential.access_key_id, credential.secret_access_key)
});
AWS.config.region = credential.s3_region;
let s3 = new AWS.S3();
this.awsS3Service.listBuckets(s3, (error, buckets) => {
this.buckets = buckets;
});
});
awsAssumeRolePromise.then(function(data) {
console.log("successfully assumed role, '" + role.roleArn + "'");
//console.log(data);
creds = new AWS.Credentials({
accessKeyId: data.Credentials.AccessKeyId,
secretAccessKey: data.Credentials.SecretAccessKey,
sessionToken: data.Credentials.SessionToken
});
if (++idx == roles.length) {
console.log("\nsuccessfully completed to assume all roles");
//input.creds = creds;
resolve(creds);
}
else {
var assumeRolePromise = assumeRole(creds, idx, roles, sessionName, input);
assumeRolePromise.then(function(data) {
resolve(data);
});
}
}).catch(function(err) {
function configureService(accessKey, secretKey, region) {
var creds = new AWS.Credentials(accessKey, secretKey);
var endpoint = "sqs.{0}.amazonaws.com";
var service = new AWS.SQS();
service.config.credentials = creds;
service.config.region = region;
endpoint = endpoint.replace("{0}", region);
service.endpoint = new AWS.Endpoint(endpoint);
return service;
}
var SqsClient = (function () {
createCredentials () {
const { key, secret, token } = this.config
return new AWS.Credentials(key, secret, token)
}
.subscribe(data => {
let accessKeyId: IFieldDefinition;
let secreteKey: IFieldDefinition;
let region: IFieldDefinition;
for (let configuration of data.settings) {
if (configuration.name === "accessKeyId") {
accessKeyId = configuration
} else if (configuration.name === "secreteAccessKey") {
secreteKey = configuration
} else if (configuration.name === "region") {
region = configuration
}
}
var sqs = new AWS.SQS({
credentials: new AWS.Credentials(accessKeyId.value, secreteKey.value), region: region.value
});
var params = {};
sqs.listQueues(params, function (err, data) {
if (err) {
observer.next(queueUrls);
} else {
observer.next(data.QueueUrls);
}
});
});
}
const accounts = [];
const keys = Object.keys(profiles);
for (const key of keys) {
if (input['--profile'] !== null && key !== input['--profile']) {
continue;
}
const profile = profiles[key];
if ('aws_access_key_id' in profile && 'aws_secret_access_key' in profile) {
const params = {
accessKeyId: profile.aws_access_key_id,
secretAccessKey: profile.aws_secret_access_key
};
if ('aws_session_token' in profile) {
params.sessionToken = profile.aws_session_token;
}
const credentials = new AWS.Credentials(params);
accounts.push(await enrichAwsAccount({
type: 'access-key',
label: `profile ${key}`,
config: {
credentials
}
}));
} else if ('role_arn' in profile && 'source_profile' in profile && 'mfa_serial' in profile) {
const sourceProfile = profiles[profile.source_profile];
const masterParams = {
accessKeyId: sourceProfile.aws_access_key_id,
secretAccessKey: sourceProfile.aws_secret_access_key
};
if ('aws_session_token' in sourceProfile) {
masterParams.sessionToken = sourceProfile.aws_session_token;
}