Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var AWSXRay = require("aws-xray-sdk-core");
var logger = require('winston');
AWSXRay.setLogger(logger);
var AWS = AWSXRay.captureAWS(require('aws-sdk'));
var docClient = new AWS.DynamoDB.DocumentClient({
apiVersion: '2012-08-10'
});
// Table name is configured as env var.
var table = process.env.TABLE_NAME;
exports.handler = (event, context, callback) => {
console.log('Received event:', JSON.stringify(event, null, 2));
var responseBody = {
message: ""
};
'use strict';
const AWSXRay = require('aws-xray-sdk-core');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
//const AWS = require('aws-sdk');
const uuidv4 = require('uuid/v4');
const crypto = require('crypto');
const kinesis = new AWS.Kinesis();
const kms = new AWS.KMS();
// function to determine if the cookie exists and is valid
const verify = (cookie, secret) => {
let segments = cookie.split('/');
return segments.length === 2 && (crypto.createHmac('sha256', secret).update(segments[0]).digest('hex') === segments[1]);
}
let secret = undefined
const decrypt = () => {
if (!secret) {
var AWSXRay = require('aws-xray-sdk-core');
var AWS = AWSXRay.captureAWS(require('aws-sdk'));
AWS.config.update({region: process.env.AWS_REGION});
var Chance = require('chance');
var myFunction = function(event, context, callback) {
var sns = new AWS.SNS();
var chance = new Chance();
var userid = event.userid;
var name = chance.first();
AWSXRay.captureFunc('annotations', function(subsegment){
subsegment.addAnnotation('Name', name);
subsegment.addAnnotation('UserID', event.userid);
});
// Notify
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
/**
* Handler functions
*/
var AWSXRay = require('aws-xray-sdk-core');
var AWS = AWSXRay.captureAWS(require('aws-sdk'));
var s3 = new AWS.S3();
var async = require('async');
var h = require('Handlebars');
var fs = require('fs');
var path = require('path');
var helpers = require('./helpers');
// Landsat - Root query, handle landing page and /sceneID
module.exports.landsatRoot = function (event, cb) {
// Handle redirect to scene page if we have a sceneID
if (event.sceneID) {
var path = event.sceneID.substr(3, 3);
var row = event.sceneID.substr(6, 3);
// Handle collections productID
if (event.sceneID.substr(0, 4) === 'LC08') {
path = event.sceneID.substr(10, 3);
// //////////////////////////////////////////////////////////////////////////////////// endregion
// region Instrumentation Functions: Trace the execution of this Sigfox Callback across multiple Cloud Functions via AWS X-Ray
// Allow AWS X-Ray to capture trace.
// eslint-disable-next-line import/no-unresolved
const AWSXRay = require('aws-xray-sdk-core');
AWSXRay.middleware.setSamplingRules({
rules: [{ description: 'sigfox-aws', service_name: '*', http_method: '*', url_path: '/*', fixed_target: 0, rate: 0.5 }],
default: { fixed_target: 1, rate: 0.5 },
version: 1,
});
// Create the AWS SDK instance.
const AWS = isProduction
? AWSXRay.captureAWS(require('aws-sdk'))
: require('aws-sdk');
if (isProduction) AWS.config.update({ region: process.env.AWS_REGION });
else AWS.config.loadFromPath('./aws-credentials.json');
// TODO: Create spans and traces for logging performance.
const rootSpanStub = {
startSpan: (/* rootSpanName, labels */) => ({
end: () => ({}),
}),
end: () => ({}),
};
const rootTraceStub = { // new tracingtrace(tracing, rootTraceId);
startSpan: (/* rootSpanName, labels */) => rootSpanStub,
end: () => ({}),
};
constructor(options: {
endpoint: string | undefined,
enableAWSXray: boolean,
}) {
const dynamoDBOptions = {
endpoint: options.endpoint,
httpOptions: {
agent: this.httpAgent(options.endpoint),
},
};
if (options.enableAWSXray) {
// Since "require" itself does something for this lib, such as logging
// importing this only when it's needed
const AWSXRay = require("aws-xray-sdk-core");
const aws = AWSXRay.captureAWS(AWS);
this.__client = new aws.DynamoDB(dynamoDBOptions);
this.__documentClient = new aws.DynamoDB.DocumentClient({
service: this.__client,
});
} else {
this.__client = new DynamoDB(dynamoDBOptions);
this.__documentClient = new DynamoDB.DocumentClient({
service: this.__client,
});
}
}
'use strict';
const AWSXRay = require('aws-xray-sdk-core');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
const uuidv4 = require('uuid/v4');
var randomstring = require('randomstring');
const kinesis = new AWS.Kinesis({
region: process.env.AWS_REGION
});
/*
* Load events into Kinesis from API gateway
*/
exports.handler = (event, context, callback) => {
// generate a random message body if not provided
if (event.body && Object.keys(event.body).length === 0) {
event.body = {
'MessageType' : 'Claps',
'MemberId' : randomstring.generate({
var sharp = require('sharp'),
AWSXRay = require('aws-xray-sdk-core'),
path = require('path'),
isAnimated = require('animated-gif-detector'),
smartcrop = require('smartcrop-sharp'),
imageminPngquant = require('imagemin-pngquant');
const enableTracing = process.env.AWS_XRAY_DAEMON_ADDRESS;
let AWS;
if ( enableTracing ) {
AWS = AWSXRay.captureAWS(require('aws-sdk'));
} else {
AWS = require('aws-sdk');
}
var regions = {};
module.exports = {};
module.exports.s3 = function(config, key, args, callback) {
AWS.config.region = config.region;
var s3config = {};
if (config.endpoint) {
s3config.endpoint = config.endpoint;
s3config.s3ForcePathStyle = true;
}
const request = require('sync-request');
const AWSXRay = require('aws-xray-sdk-core');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
AWS.config.update({region: process.env.AWS_REGION});
var ssm = new AWS.SSM();
const api_base = "https://api2.cloudcheckr.com/";
var cc_admin_access_key = '';
function processEvent(event, context, callback) {
var masterPayerArr;
try {
var params = {
Names: [
'html_encoded_semicolon_separated_master_payers'
]
};
exports.captureWithXRay = function (awsSdk) {
const xray = require('aws-xray-sdk-core');
xray.captureHTTPsGlobal(require('http'));
xray.capturePromise();
return xray.captureAWS(awsSdk);
};