+38
-34
@@ -1,27 +0,30 @@ | ||
| const GetOpt = require("node-getopt"); | ||
| const { program } = require("commander"); | ||
| const AWS = require("aws-sdk"); | ||
| const Lib = require(__dirname + "/src/lib.js"); | ||
| const parsedArgs = GetOpt.create([ | ||
| ["h", "help", "shows help"], | ||
| ["p", "profile=PROFILE", "aws profile"], | ||
| ["r", "region=REGION", "aws region"], | ||
| ["", "ecs-create-new-revision-for-container", "create a new ecs revision, updating a container"], | ||
| ["", "ecr-login", "login to ecr"], | ||
| ["", "ecr-tag-push", "tag and push to ecr"], | ||
| ["", "ecr-ecs-push-new-revision", "tags image, pushes, and creates a new revision"], | ||
| //["", "lambda-kill-warm-instances", "kill warm lambda instances by doing a silent redeployment"], | ||
| ["", "task-definition=TASKDEFINITION", "ecs task definition"], | ||
| ["", "container-name=CONTAINERNAME", "container name"], | ||
| ["", "image-name=IMAGENAME", "image name"], | ||
| ["", "local-image-name=IMAGENAME", "local-image name"], | ||
| ["", "lambda-function=LAMBDAFUNCTION", "lambda function name"] | ||
| ]).bindHelp().parseSystem(); | ||
| program | ||
| .option("-p, --profile <profile>", "aws profile") | ||
| .option("-r, --region <region>", "aws region") | ||
| .option("--ecs-create-new-revision-for-container", "create a new ecs revision, updating a container") | ||
| .option("--ecr-login", "login to ecr") | ||
| .option("--ecr-tag-push", "tag and push to ecr") | ||
| .option("--ecr-ecs-push-new-revision", "tags image, pushes, and creates a new revision") | ||
| .option("--edge-lambda-kill-warm-instances", "kill warm edge lambda instances by doing a silent redeployment") | ||
| .option("--task-definition <task-definition>", "ecs task definition") | ||
| .option("--container-name <container-name>", "container name") | ||
| .option("--image-name <image-name>", "image name") | ||
| .option("--local-image-name <local-image-name>", "local image name") | ||
| .option("--lambda-function <lambda-function>", "lambda function") | ||
| .option("--lambda-edge-type <lambda-edge-type>", "lambda edge type") | ||
| .option("--cloudfront-id <cloudfront-id>", "cloudfront id"); | ||
| if (parsedArgs.options.region) | ||
| AWS.config.update({region: parsedArgs.options.region}); | ||
| program.parse(process.argv); | ||
| const options = program.opts(); | ||
| if (parsedArgs.options.profile) | ||
| AWS.config.update({credentials: new AWS.SharedIniFileCredentials({profile: parsedArgs.options.profile})}); | ||
| if (options.region) | ||
| AWS.config.update({region: options.region}); | ||
| if (options.profile) | ||
| AWS.config.update({credentials: new AWS.SharedIniFileCredentials({profile: options.profile})}); | ||
| const resultFunc = function (err, data) { | ||
@@ -32,20 +35,21 @@ console.log(err ? err : data); | ||
| if (parsedArgs.options["ecs-create-new-revision-for-container"]) | ||
| Lib.ecsCreateNewRevisionForContainer(parsedArgs.options["task-definition"], parsedArgs.options["container-name"], parsedArgs.options["image-name"], resultFunc); | ||
| if (options["ecsCreateNewRevisionForContainer"]) | ||
| Lib.ecsCreateNewRevisionForContainer(options["taskDefinition"], options["containerName"], options["imageName"], resultFunc); | ||
| if (parsedArgs.options["ecr-login"]) | ||
| if (options["ecrLogin"]) | ||
| Lib.ecrLogin(resultFunc); | ||
| if (parsedArgs.options["ecr-tag-push"]) | ||
| Lib.ecrTagPush(parsedArgs.options["local-image-name"], parsedArgs.options["image-name"], resultFunc); | ||
| if (options["ecrTagPush"]) | ||
| Lib.ecrTagPush(options["localImageName"], options["imageName"], resultFunc); | ||
| if (parsedArgs.options["ecr-ecs-push-new-revision"]) | ||
| Lib.ecrEcsPushNewRevision(parsedArgs.options["task-definition"], parsedArgs.options["container-name"], parsedArgs.options["local-image-name"], parsedArgs.options["image-name"], resultFunc); | ||
| /* | ||
| if (parsedArgs.options["lambda-kill-warm-instances"]) | ||
| Lib.lambdaKillWarmInstances(parsedArgs.options["lambda-function"], resultFunc); | ||
| */ | ||
| // TODO: lambda version based routing | ||
| if (options["ecrEcsPushNewRevision"]) | ||
| Lib.ecrEcsPushNewRevision(options["taskDefinition"], options["containerName"], options["localImageName"], options["imageName"], resultFunc); | ||
| if (options["edgeLambdaKillWarmInstances"]) | ||
| Lib.edgeLambdaKillWarmInstances(options["lambdaFunction"], options["cloudfrontId"], options["lambdaEdgeType"], resultFunc); | ||
| // TODO: lambda version based routing deploy | ||
| // TODO: run temporarily on fargate | ||
| // TODO: lambda flush cache | ||
| // TODO: run task on aws/fargate | ||
| // TODO: lambda flush cache normal lambda | ||
| // TODO: run task on aws/fargate |
+2
-2
| { | ||
| "name": "awsass", | ||
| "description": "AWSASS is an assistant to AWS, mostly for running better scripts.", | ||
| "version": "0.0.6", | ||
| "version": "0.0.7", | ||
| "author": "Jsonize", | ||
@@ -17,3 +17,3 @@ "repository": "https://github.com/jsonize/awsass", | ||
| "aws-sdk": "", | ||
| "node-getopt": "git+https://git@github.com/tuxpoldo/node-getopt" | ||
| "commander": "^8.3.0" | ||
| }, | ||
@@ -20,0 +20,0 @@ "files": [ |
+46
-4
@@ -95,10 +95,52 @@ const AWS = require("aws-sdk"); | ||
| }); | ||
| }/*, | ||
| }, | ||
| lambdaKillWarmInstances: function (lambdaFunction, callback) { | ||
| edgeLambdaKillWarmInstances: function (lambdaFunction, cloudfrontId, lambdaEdgeType, callback) { | ||
| const lambda = new AWS.Lambda({apiVersion: '2015-03-31'}); | ||
| const cloudfront = new AWS.CloudFront({apiVersion: '2020-05-31'}); | ||
| lambda.updateFunctionConfiguration({ | ||
| FunctionName: lambdaFunction, | ||
| Description: "AWSASS:" + (new Date()).getTime() | ||
| }, function (err) { | ||
| if (err) { | ||
| callback(err); | ||
| return; | ||
| } | ||
| setTimeout(function () { | ||
| lambda.publishVersion({ | ||
| FunctionName: lambdaFunction | ||
| }, function (err, publishResult) { | ||
| if (err) { | ||
| callback(err); | ||
| return; | ||
| } | ||
| cloudfront.getDistributionConfig({ | ||
| Id: cloudfrontId | ||
| }, function (err, distributionConfig) { | ||
| if (err) { | ||
| callback(err); | ||
| return; | ||
| } | ||
| const lambdaItems = distributionConfig.DistributionConfig.DefaultCacheBehavior.LambdaFunctionAssociations.Items; | ||
| let lambdaItem = null; | ||
| lambdaItems.forEach(function (candidate) { | ||
| if (candidate.EventType === lambdaEdgeType) | ||
| lambdaItem = candidate; | ||
| }); | ||
| let s = lambdaItem.LambdaFunctionARN.split(":"); | ||
| s[s.length - 1] = publishResult.Version; | ||
| lambdaItem.LambdaFunctionARN = s.join(":"); | ||
| cloudfront.updateDistribution({ | ||
| Id: cloudfrontId, | ||
| IfMatch: distributionConfig.ETag, | ||
| DistributionConfig: distributionConfig.DistributionConfig | ||
| }, callback); | ||
| }); | ||
| }); | ||
| }, 5000); | ||
| }); | ||
| } | ||
| }*/ | ||
| }; | ||
| module.exports = Module; |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable and can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
9799
25.82%193
29.53%0
-100%1
-50%+ Added
+ Added
- Removed