def lambda_handler(event, context): settings = config.load() if settings.aws_region: storage.set_region(config.get_value("aws_region")) if settings.storage: storage_options = config.get_value("storage") storage.set_options(storage_options) enable_vulnerability_alerts()
def test_read_s3(): """ This test only works if AWS credentials are available.. ..and there is an S3 bucket to read/write from. The API call is not mocked. """ if ("AWS_SECRET_ACCESS_KEY" not in os.environ and os.environ["FLASK_ENV"] != "production"): pytest.skip() storage.set_region(REGION) storage.set_options(S3_OPTIONS) parsed = storage.read_json(path) assert parsed.test1 == content.test1, "Read S3 object matches saved content"
def test_save_s3(): """ This test only works if AWS credentials are available.. ..and there is an S3 bucket to read/write from. The API call is not mocked. """ if ("AWS_SECRET_ACCESS_KEY" not in os.environ and os.environ["FLASK_ENV"] != "production"): pytest.skip() storage.set_region(REGION) storage.set_options(S3_OPTIONS) status = storage.save(path, json.dumps(content, indent=2)) assert status, "S3 put object reported success"
def test_get_set_options(): storage.set_options(LOCAL_OPTIONS) options = storage.get_options() assert options.type == "local", "Options type is correct" assert options.location == "output", "Options location is correct"
from splunk import Splunk from concurrent.futures import ThreadPoolExecutor log.basicConfig( format="%(asctime)-15s [%(levelname)s] %(funcName)s: %(message)s", level=log.DEBUG) settings = config.load() if settings.aws_region: storage.set_region(config.get_value("aws_region")) if settings.storage: storage_options = config.get_value("storage") storage.set_options(storage_options) def get_adv_status(repo): response = github_rest_client.get( f"/repos/{repo.owner.login}/{repo.name}/vulnerability-alerts") alerts_enabled = response.status_code == 204 vulnerable = repo.vulnerabilityAlerts.edges if vulnerable: repo.status = "vulnerable" elif alerts_enabled: repo.status = "clean" else: repo.status = "disabled"