Skip to content

Conversation

@williambrady
Copy link
Owner

Summary

Migrates all content from portfolio-template-sdlc to establish this as an actively developed example project.

Added

  • Python Application - scripts/ with example code and tests/ with pytest suite
  • Terraform IaC - terraform/ with AWS resource configurations
  • CloudFormation - cloudformation/ with example templates
  • Docker - Dockerfile and .dockerignore
  • CI/CD Workflows:
    • ci-cd.yml - Build, test, and deploy pipeline
    • sast.yml - Security scanning with SDLC Code Scanner
    • terraform.yml - Infrastructure validation
  • Code Quality - Pre-commit hooks, flake8, black, pylint, bandit configs
  • License - PolyForm Noncommercial License 1.0.0

Expected Security Findings

As documented in the README, the security scan will report ~36 findings:

  • Terraform: ~19 (HIGH/MEDIUM)
  • CloudFormation: ~5 (MEDIUM)
  • Python/Pylint: ~12 (LOW/INFO)

These are intentional for demonstration purposes.

🤖 Generated with Claude Code

Adds:
- Python application (scripts/) with tests
- Terraform IaC configurations
- CloudFormation example templates
- Docker configuration
- CI/CD workflows (ci-cd, sast, terraform)
- Pre-commit hooks configuration
- Code quality tooling (flake8, black, pylint, etc.)

Note: Security scan will report ~36 findings as documented in README.
These are intentional for demonstration purposes.
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

5 similar comments
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

Value: CloudFormation

# Example CloudWatch Log Group
ExampleLogGroup:

Check failure

Code scanning / SDLC Code Scanner (checkov-cfn)

Ensure that CloudWatch Log Group is encrypted by KMS High

Ensure that CloudWatch Log Group is encrypted by KMS | FAILED | Resource: AWS::Logs::LogGroup.ExampleLogGroup

Resources:
# Example S3 bucket with security best practices
ExampleBucket:

Check warning

Code scanning / SDLC Code Scanner (checkov-cfn)

Ensure the S3 bucket has access logging enabled Medium

Ensure the S3 bucket has access logging enabled | FAILED | Resource: AWS::S3::Bucket.ExampleBucket
Resources:
# Example S3 bucket with security best practices
ExampleBucket:
Type: AWS::S3::Bucket

Check warning

Code scanning / SDLC Code Scanner (cfn-nag)

S3 bucket should likely have a bucket policy Medium

S3 bucket should likely have a bucket policy | Resource: ExampleBucket
Resources:
# Example S3 bucket with security best practices
ExampleBucket:
Type: AWS::S3::Bucket

Check warning

Code scanning / SDLC Code Scanner (cfn-nag)

S3 Bucket should have access logging configured Medium

S3 Bucket should have access logging configured | Resource: ExampleBucket

# Example CloudWatch Log Group
ExampleLogGroup:
Type: AWS::Logs::LogGroup

Check warning

Code scanning / SDLC Code Scanner (cfn-nag)

CloudWatchLogs LogGroup should specify a KMS Key Id to encrypt the log data Medium

CloudWatchLogs LogGroup should specify a KMS Key Id to encrypt the log data | Resource: ExampleLogGroup
}

# CloudWatch Log Group for application logs
resource "aws_cloudwatch_log_group" "app_logs" {

Check failure

Code scanning / SDLC Code Scanner (checkov)

Ensure that CloudWatch Log Group is encrypted by KMS High

Ensure that CloudWatch Log Group is encrypted by KMS | FAILED | Resource: aws_cloudwatch_log_group.app_logs
}

# S3 Bucket for data storage and long-term log archival
resource "aws_s3_bucket" "data_bucket" {

Check failure

Code scanning / SDLC Code Scanner (checkov)

Ensure that S3 buckets are encrypted with KMS by default High

Ensure that S3 buckets are encrypted with KMS by default | FAILED | Resource: aws_s3_bucket.data_bucket
}

# CloudWatch Log Group for application logs
resource "aws_cloudwatch_log_group" "app_logs" {

Check warning

Code scanning / SDLC Code Scanner (checkov)

Ensure CloudWatch log groups retains logs for at least 1 year Medium

Ensure CloudWatch log groups retains logs for at least 1 year | FAILED | Resource: aws_cloudwatch_log_group.app_logs
}

# S3 Bucket for data storage and long-term log archival
resource "aws_s3_bucket" "data_bucket" {

Check warning

Code scanning / SDLC Code Scanner (checkov)

Ensure S3 buckets should have event notifications enabled Medium

Ensure S3 buckets should have event notifications enabled | FAILED | Resource: aws_s3_bucket.data_bucket
}

# S3 Bucket for data storage and long-term log archival
resource "aws_s3_bucket" "data_bucket" {

Check warning

Code scanning / SDLC Code Scanner (checkov)

Ensure the S3 bucket has access logging enabled Medium

Ensure the S3 bucket has access logging enabled | FAILED | Resource: aws_s3_bucket.data_bucket
}

# S3 Bucket for data storage and long-term log archival
resource "aws_s3_bucket" "data_bucket" {

Check warning

Code scanning / SDLC Code Scanner (checkov)

Ensure that S3 bucket has cross-region replication enabled Medium

Ensure that S3 bucket has cross-region replication enabled | FAILED | Resource: aws_s3_bucket.data_bucket
}

# S3 Bucket lifecycle policy
resource "aws_s3_bucket_lifecycle_configuration" "data_bucket_lifecycle" {

Check warning

Code scanning / SDLC Code Scanner (checkov)

Ensure S3 lifecycle configuration sets period for aborting failed uploads Medium

Ensure S3 lifecycle configuration sets period for aborting failed uploads | FAILED | Resource: aws_s3_bucket_lifecycle_configuration.data_bucket_lifecycle
}

# Enable encryption for S3 bucket
resource "aws_s3_bucket_server_side_encryption_configuration" "data_bucket_encryption" {

Check failure

Code scanning / SDLC Code Scanner (tfsec)

S3 encryption should use Customer Managed Keys High

S3 encryption should use Customer Managed Keys | Bucket does not encrypt data with a customer managed key. | Resource: aws_s3_bucket_server_side_encryption_configuration.data_bucket_encryption
role = aws_iam_role.app_role.id

policy = jsonencode({
Version = "2012-10-17"

Check failure

Code scanning / SDLC Code Scanner (tfsec)

IAM policy should avoid use of wildcards and instead apply the principle of least privilege High

IAM policy should avoid use of wildcards and instead apply the principle of least privilege | IAM policy document uses sensitive action 'logs:CreateLogGroup' on wildcarded resource '0c5ed373-2321-44aa-89cf-94eaf272808a:*' | Resource: aws_iam_role_policy.cloudwatch_logs_policy
role = aws_iam_role.app_role.id

policy = jsonencode({
Version = "2012-10-17"

Check failure

Code scanning / SDLC Code Scanner (tfsec)

IAM policy should avoid use of wildcards and instead apply the principle of least privilege High

IAM policy should avoid use of wildcards and instead apply the principle of least privilege | IAM policy document uses sensitive action 's3:GetObject' on wildcarded resource 'c23e01a7-0fde-4d4e-9fe9-ba5a49bbdaf4' | Resource: aws_iam_role_policy.s3_access_policy
}

# S3 Bucket for data storage and long-term log archival
resource "aws_s3_bucket" "data_bucket" {

Check warning

Code scanning / SDLC Code Scanner (tfsec)

S3 Bucket does not have logging enabled. Medium

S3 Bucket does not have logging enabled. | Bucket does not have logging enabled | Resource: aws_s3_bucket.data_bucket
}

# CloudWatch Log Group for application logs
resource "aws_cloudwatch_log_group" "app_logs" {

Check notice

Code scanning / SDLC Code Scanner (tfsec)

CloudWatch log groups should be encrypted using CMK Low

CloudWatch log groups should be encrypted using CMK | Log group is not encrypted. | Resource: aws_cloudwatch_log_group.app_logs
self.environment = environment
self.s3_client: Optional[boto3.client] = None
self.cloudwatch_client: Optional[boto3.client] = None
logger.info(f"Initializing DataProcessor for environment: {environment}")

Check warning

Code scanning / SDLC Code Scanner (pylint)

logging-fstring-interpolation: Use lazy % formatting in logging functions Medium

logging-fstring-interpolation: Use lazy % formatting in logging functions | Use lazy % formatting in logging functions
self.cloudwatch_client = boto3.client("logs")
logger.info("AWS clients initialized successfully")
except ClientError as e:
logger.error(f"Failed to initialize AWS clients: {e}")

Check warning

Code scanning / SDLC Code Scanner (pylint)

logging-fstring-interpolation: Use lazy % formatting in logging functions Medium

logging-fstring-interpolation: Use lazy % formatting in logging functions | Use lazy % formatting in logging functions
Returns:
Dictionary containing processing results
"""
logger.info(f"Processing data: {input_data}")

Check warning

Code scanning / SDLC Code Scanner (pylint)

logging-fstring-interpolation: Use lazy % formatting in logging functions Medium

logging-fstring-interpolation: Use lazy % formatting in logging functions | Use lazy % formatting in logging functions

try:
self.s3_client.put_object(Bucket=bucket, Key=key, Body=data)
logger.info(f"Successfully saved data to s3://{bucket}/{key}")

Check warning

Code scanning / SDLC Code Scanner (pylint)

logging-fstring-interpolation: Use lazy % formatting in logging functions Medium

logging-fstring-interpolation: Use lazy % formatting in logging functions | Use lazy % formatting in logging functions
logger.info(f"Successfully saved data to s3://{bucket}/{key}")
return True
except ClientError as e:
logger.error(f"Failed to save to S3: {e}")

Check warning

Code scanning / SDLC Code Scanner (pylint)

logging-fstring-interpolation: Use lazy % formatting in logging functions Medium

logging-fstring-interpolation: Use lazy % formatting in logging functions | Use lazy % formatting in logging functions
logging.getLogger().setLevel(logging.DEBUG)

logger.info("Starting Portfolio Data Processing Application")
logger.info(f"Environment: {args.environment}")

Check warning

Code scanning / SDLC Code Scanner (pylint)

logging-fstring-interpolation: Use lazy % formatting in logging functions Medium

logging-fstring-interpolation: Use lazy % formatting in logging functions | Use lazy % formatting in logging functions
# Process data if input provided
if args.input:
result = processor.process_data(args.input)
logger.info(f"Processing result: {result}")

Check warning

Code scanning / SDLC Code Scanner (pylint)

logging-fstring-interpolation: Use lazy % formatting in logging functions Medium

logging-fstring-interpolation: Use lazy % formatting in logging functions | Use lazy % formatting in logging functions
logger.info("Application completed successfully")
return 0

except Exception as e:

Check warning

Code scanning / SDLC Code Scanner (pylint)

broad-exception-caught: Catching too general exception Exception Medium

broad-exception-caught: Catching too general exception Exception | Catching too general exception Exception
return 0

except Exception as e:
logger.error(f"Application failed: {e}", exc_info=True)

Check warning

Code scanning / SDLC Code Scanner (pylint)

logging-fstring-interpolation: Use lazy % formatting in logging functions Medium

logging-fstring-interpolation: Use lazy % formatting in logging functions | Use lazy % formatting in logging functions
pass # Stream might already exist

# Send log event
import time

Check notice

Code scanning / SDLC Code Scanner (pylint)

import-outside-toplevel: Import outside toplevel (time) Low

import-outside-toplevel: Import outside toplevel (time) | Import outside toplevel (time)
@github-actions
Copy link

SDLC Code Scanner Security Scan ❌

Severity Count
Critical 0
High 9
Medium 21
Low 5
Total 36

View the full report in the Actions artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants