How to use the responses.server_error function in responses

To help you get started, we’ve selected a few responses examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dowjones / hammer / hammer / identification / lambdas / api / secgrp_unrestricted_access.py View on Github external
checker = SecurityGroupsChecker(account=account,
                                restricted_ports=config.sg.restricted_ports)
    if checker.check(ids=ids):
        for sg in checker.groups:
            processed = sg.restrict(RestrictionStatus.OpenCompletely)
            if processed == 0:
                 result = "skipped"
            elif processed is None:
                result = "failed"
            else:
                result = "remediated"
            response[security_feature][sg.id] = result
        return response
    else:
        return server_error(text="Failed to check insecure services")
github dowjones / hammer / hammer / identification / lambdas / api / s3_bucket_acl.py View on Github external
}

    checker = S3BucketsAclChecker(account=account)
    if checker.check(buckets=ids):
        for bucket in checker.buckets:
            if not bucket.public_by_acl:
                result = "skipped"
            else:
                if bucket.restrict_acl():
                    result = "remediated"
                else:
                    result = "failed"
            response[security_feature][bucket.name] = result
        return response
    else:
        return server_error(text="Failed to check S3 ACL")
github dowjones / hammer / hammer / identification / lambdas / api / ebs_unencrypted_volume.py View on Github external
result.append({
                    'id': volume.id,
                    'name': volume.name,
                    'state': volume.state,
                })
        response = {
            security_feature: result,
            'checked_volumes': volumes,
        }
        if ids:
            response.setdefault("filterby", {})["ids"] = ids
        if tags:
            response.setdefault("filterby", {})["tags"] = tags
        return response
    else:
        return server_error(text="Failed to check EBS unencrypted volumes")
github dowjones / hammer / hammer / identification / lambdas / api / s3_bucket_acl.py View on Github external
continue
            buckets.append(f"{bucket.name}")
            if bucket.public:
                result.append({
                    'name': bucket.name,
                    'public_acls': bucket.get_public_acls(),
                })
        response = {
            security_feature: result,
            'checked_buckets': buckets,
        }
        if ids:
            response.setdefault("filterby", {})["ids"] = ids
        return response
    else:
        return server_error(text="Failed to check S3 public acls")
github dowjones / hammer / hammer / identification / lambdas / api / s3_encryption.py View on Github external
}

    checker = S3EncryptionChecker(account=account)
    if checker.check(buckets=ids):
        for bucket in checker.buckets:
            if bucket.encrypted:
                result = "skipped"
            else:
                if bucket.encrypt_bucket():
                    result = "remediated"
                else:
                    result = "failed"
            response[security_feature][bucket.name] = result
        return response
    else:
        return server_error(text="Failed to check S3 encryption")
github dowjones / hammer / hammer / identification / lambdas / api / rds_encryption.py View on Github external
def identify(security_feature, account, config, ids, tags):
    checker = RdsEncryptionChecker(account=account)
    result = []
    if checker.check():
        for instance in checker.instances:
            result.append({
                'name': instance.name,
                'id': instance.id,
                'engine': instance.engine,
            })
        response = {
            security_feature: result
        }
        return response
    else:
        return server_error(text="Failed to check RDS instance un-encryption")
github dowjones / hammer / hammer / identification / lambdas / api / ebs_public_snapshot.py View on Github external
if checker.check(ids=ids, tags=tags):
        snapshots = []
        for snapshot in checker.snapshots:
            snapshots.append(f"{snapshot.id}")
            if snapshot.public:
                result.append({
                    'id': snapshot.id,
                    'volume_id': snapshot.volume_id,
                })
        response = {
            security_feature: result,
            'checked_snapshots': snapshots,
        }
        return response
    else:
        return server_error(text="Failed to check EBS public snapshots")
github dowjones / hammer / hammer / identification / lambdas / api / secgrp_unrestricted_access.py View on Github external
'id': sg.id,
                    'name': sg.name,
                    'status': sg.status.value,
                    'permissions': permissions,
                })
        response = {
            security_feature: result,
            'checked_groups': groups,
        }
        if ids:
            response.setdefault("filterby", {})["ids"] = ids
        if tags:
            response.setdefault("filterby", {})["tags"] = tags
        return response
    else:
        return server_error(text="Failed to check insecure services")
github dowjones / hammer / hammer / identification / lambdas / api / rds_public_snapshot.py View on Github external
def identify(security_feature, account, config, ids, tags):
    checker = RdsSnapshotsChecker(account=account)
    result = []
    if checker.check():
        for snapshot in checker.snapshots:
            result.append({
                'name': snapshot.name,
                'db': snapshot.db,
                'engine': snapshot.engine,
            })
        response = {
            security_feature: result
        }
        return response
    else:
        return server_error(text="Failed to check RDS public snapshots")
github dowjones / hammer / hammer / identification / lambdas / api / s3_bucket_policy.py View on Github external
continue
            buckets.append(f"{bucket.name}")
            if bucket.public:
                result.append({
                    'name': bucket.name,
                    'policy': bucket.policy,
                })
        response = {
            security_feature: result,
            'checked_buckets': buckets,
        }
        if ids:
            response.setdefault("filterby", {})["ids"] = ids
        return response
    else:
        return server_error(text="Failed to check S3 public policies")