コード例 #1
0
def test_checkBucketWithoutCreds():
    """
    Scenario checkBucketwc.1 - Non-existent bucket
    Scenario checkBucketwc.2 - Good bucket
    Scenario checkBucketwc.3 - No public read perm
    """
    test_setup()

    if s3.awsCredsConfigured:
        return

    # checkBucketwc.1
    assert s3.checkBucketWithoutCreds('ireallyhopethisbucketdoesntexist') is False

    # checkBucketwc.2
    assert s3.checkBucketWithoutCreds('flaws.cloud') is True

    # checkBucketwc.3
    assert s3.checkBucketWithoutCreds('blog') is True
コード例 #2
0
ファイル: s3scanner.py プロジェクト: sanelez/S3Scanner
        elif ":" in line:  # We were given a bucket in 'bucket:region' format
            bucket = line.split(":")[0]
        else:  # We were either given a bucket name or domain name
            bucket = line

        valid = s3.checkBucketName(bucket)

        if not valid:
            message = "{0:>11} : {1}".format("[invalid]", bucket)
            slog.error(message)
            continue

        if s3.awsCredsConfigured:
            b = s3.checkAcl(bucket)
        else:
            a = s3.checkBucketWithoutCreds(bucket)
            b = {"found": a, "acls": "unknown - no aws creds"}

        if b["found"]:

            size = s3.getBucketSize(
                bucket)  # Try to get the size of the bucket

            message = "{0:>11} : {1}".format(
                "[found]",
                bucket + " | " + size + " | ACLs: " + str(b["acls"]))
            slog.info(message)
            flog.debug(bucket)

            if args.dump:
                s3.dumpBucket(bucket)