Skip to content

Instantly share code, notes, and snippets.

View hendrixroa's full-sized avatar
🏠
Working from home

Hendrix Roa hendrixroa

🏠
Working from home
View GitHub Profile
@hendrixroa
hendrixroa / AWSSecretsByKeys.ts
Created January 18, 2020 21:57
Pull aws secrets values given keys.
import AWS = require('aws-sdk');
import minimist = require('minimist');
const args: any = minimist(process.argv);
const secretsManager = new AWS.SecretsManager({
region: process.env.AWS_DEFAULT_REGION || 'us-east-2',
});
export class SecretByKey {
public getSecretByKey(secretId: string, keys: string[]): Promise<any> {
@hendrixroa
hendrixroa / GetGitMessages.ts
Created January 18, 2020 21:58
Get current git message and print into stdout
import { spawnSync } from 'child_process';
const child = spawnSync('git', ['log', '-1', '--pretty=format:%s']);
if (child.error) {
// tslint:disable-next-line: no-console
console.error(null);
process.exit(1);
}
// tslint:disable-next-line: no-console
console.log(
@hendrixroa
hendrixroa / putRestApi.ts
Created January 18, 2020 22:03
Script to put rest api in format swagger to AWS APIGATEWAY
import AWS = require('aws-sdk');
import fs = require('fs');
import minimist = require('minimist');
const args: any = minimist(process.argv);
const apigateway = new AWS.APIGateway({
region: process.env.AWS_DEFAULT_REGION || 'us-east-2',
});
@hendrixroa
hendrixroa / yarnAudit.ts
Created January 18, 2020 22:14
Script to report yarn audit vulnerabilities to slack channet, for run 'yarn audit --json > yarn_audit.json' and later 'node -r ts-node/register scripts/yarnAudit.ts PATH_FILE MODULE'
import * as fs from 'fs';
import * as _ from 'lodash';
import { RequestAPI, RequiredUriUrl } from 'request';
import * as request from 'request-promise-native';
export class YarnAudit {
private client: RequestAPI<
request.RequestPromise,
request.RequestPromiseOptions,
RequiredUriUrl
@hendrixroa
hendrixroa / SnykAudit.ts
Last active January 18, 2020 22:15
Snyk (snyk.io) script to find vulnerabilities and report to slack via webhook, for run this script you should run first `snyk test --docker $IMAGE_BH --file=Dockerfile --json > snyk_docker.json || true` and later ` node -r ts-node/register snykAudit.ts`
import * as fs from 'fs';
import * as _ from 'lodash';
import { RequestAPI, RequiredUriUrl } from 'request';
import * as request from 'request-promise-native';
export class SnykDockerAudit {
private client: RequestAPI<
request.RequestPromise,
request.RequestPromiseOptions,
RequiredUriUrl
@hendrixroa
hendrixroa / CodedeployTriggerToSlack.ts
Created January 18, 2020 22:28
AWS Lambda function triggered by aws codedeploy to send a notification to slack if a deployment was successful or not
const axios = require('axios');
const AWS = require('aws-sdk');
const FunctionShield = require('@puresec/function-shield');
const ENV = process.env;
const slackInfraAlertBot = 'your slack bot token';
FunctionShield.configure(
{
policy: {
@hendrixroa
hendrixroa / CloudwatchLogsToElasticSearch.ts
Created January 18, 2020 22:31
AWS Lambda function to stream cloudwatch logs to elasticsearch with some modification to accept multiples indices
const https = require('https');
const zlib = require('zlib');
const crypto = require('crypto');
const FunctionShield = require('@puresec/function-shield');
const ENV = process.env;
const endpoint = ENV.es_endpoint;
FunctionShield.configure(
{
@hendrixroa
hendrixroa / yarn_audit.bash
Last active March 1, 2023 01:51
yarn audit command to get json data
yarn audit --json > yarn_audit.json
{
"type":"auditAdvisory",
"data":{
"resolution":{
"id":1091144,
"path":"swagger-ui>@braintree/sanitize-url",
"dev":false,
"optional":false,
"bundled":false
},
{
"type":"auditSummary",
"data":{
"vulnerabilities":{
"info":0,
"low":19,
"moderate":92,
"high":121,
"critical":28
},