This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io, json | |
import brevitycore.core | |
def prepareHttpx(programName,inputBucketName, fileName): | |
# Anything other than initial will default to this | |
gospiderPath = programName + '-urls-mod.txt' | |
# If operation is initial, it will be domains-new as filename | |
diffPath = programName + '-domains-new.csv' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json, boto3, os | |
import brevityprogram.programs | |
import brevityscope.scope | |
def lambda_handler(event, context): | |
eventinput = json.loads(event['body']) | |
if eventinput['program'] is None: | |
return {"isBase64Encoded":False,"statusCode":400,"body":json.dumps({"error":"Missing program name."})} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import botocore | |
from botocore.exceptions import ClientError | |
from dynamodb_json import json_util as dynjson | |
def create_program(programName): | |
try: | |
program = { | |
'ProgramName': programName | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ast | |
import re | |
import urllib.request, json | |
from urllib.parse import urlparse | |
def parseScopeIn(scopeIn): | |
targetData = [] | |
if not scopeIn: | |
return targetData | |
smallAll = str(scopeIn)[1:-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json, boto3 | |
import ast | |
import urllib.request | |
import pandas as pd | |
import numpy as np | |
import brevityscope.scope | |
import brevityprogram.programs | |
def lambda_handler(event, context): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json, boto3, os | |
def lambda_handler(event, context): | |
# This section validates whether the expected query parameters exist. | |
if event['queryStringParameters']['program'] is None: | |
return {"isBase64Encoded":False,"statusCode":400,"body":json.dumps({"error":"Missing program name."})} | |
if event['queryStringParameters']['operation'] is None: | |
return {"isBase64Encoded":False,"statusCode":400,"body":json.dumps({"error":"Missing operation name."})} | |
programName = str(event['queryStringParameters']['program']) | |
operationName = str(event['queryStringParameters']['operation']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json, boto3, os | |
def lambda_handler(event, context): | |
if event['queryStringParameters']['program'] is None: | |
return {"isBase64Encoded":False,"statusCode":400,"body":json.dumps({"error":"Missing program name."})} | |
if event['queryStringParameters']['operation'] is None: | |
return {"isBase64Encoded":False,"statusCode":400,"body":json.dumps({"error":"Missing operation name."})} | |
programName = str(event['queryStringParameters']['program']) | |
operationName = str(event['queryStringParameters']['operation']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generateScriptStepFunctions(programName, taskToken, operationName): | |
secretName = 'exampleSecretsManager' | |
regionName = 'us-east-1' | |
secretRetrieved = brevitycore.core.get_secret(secretName,regionName) | |
secretjson = json.loads(secretRetrieved) | |
awsAccessKeyId = secretjson['AWS_ACCESS_KEY_ID'] | |
awsSecretKey = secretjson['AWS_SECRET_ACCESS_KEY'] | |
stateInput = '{"program":"' + programName + '","operation":"' + operationName + '","statusCode":200}' | |
fileBuffer = io.StringIO() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json, boto3, os, re | |
def lambda_handler(event, context): | |
if event['program'] is None: | |
return {"isBase64Encoded":False,"statusCode":400,"body":json.dumps({"error":"Missing program name."})} | |
if event['operation'] is None: | |
return {"isBase64Encoded":False,"statusCode":400,"body":json.dumps({"error":"Missing operation name."})} | |
else: | |
operationName = str(event['operation']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tldextract | |
import pandas as pd | |
def parseRootDomains(refinedBucketPath, programName): | |
storePathInitial = refinedBucketPath + programName + '/' + programName + '-domains.csv' | |
dfAllDomains = pd.read_csv(storePathInitial) | |
allDomains = dfAllDomains['domain'].unique().tolist() | |
domainEdges = [] | |
for val in allDomains: | |
domainEdges.append(processDomainRoots(val)) |