AWS CodeCommit Integration
CodeScan connects to any AWS CodeCommit repository, runs a full AI security scan across your source files, and — with one click or one command — opens a Pull Request in your AWS Console with every vulnerability patched.
What you need before you start
Step 1 — Find your repository name and region
CodeScan needs only the repository name (not the full ARN) and the AWS region it lives in.
1a. Repository name
- Sign in to the AWS Management Console
- Navigate to Developer Tools → CodeCommit → Repositories
- The Name column shows the exact repository name to use — copy it
1b. Region
The region is visible in the top-right corner of the AWS Console or in the repository URL:
# URL pattern — region is the first segment after amazonaws.com
https://us-east-1.console.aws.amazon.com/codesuite/codecommit/repositories/my-backend-api
# ^^^^^^^^^^
# Common region codes
us-east-1 US East (N. Virginia)
us-west-2 US West (Oregon)
eu-west-1 Europe (Ireland)
eu-central-1 Europe (Frankfurt)
ap-southeast-1 Asia Pacific (Singapore)
ap-northeast-1 Asia Pacific (Tokyo)Step 2 — Create an IAM user with minimal CodeCommit permissions
Never use your root account credentials. Create a dedicated IAM user so you can scope permissions tightly and rotate the key independently.
2a. Create the IAM user
- In the AWS Console, go to IAM → Users → Create user
- Enter a name, e.g.
codescan-scanner - On the Set permissions page, choose Attach policies directly
- Click Create policy (opens new tab) and paste the JSON below
- Name the policy
CodeScanMinimalAccessand create it - Back on the user creation page, attach
CodeScanMinimalAccess - Complete user creation
Minimal IAM policy — paste this exactly
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CodeScanReadWrite",
"Effect": "Allow",
"Action": [
"codecommit:GetBranch",
"codecommit:GetRepository",
"codecommit:GetFolder",
"codecommit:GetFile",
"codecommit:CreateBranch",
"codecommit:CreateCommit",
"codecommit:CreatePullRequest"
],
"Resource": "arn:aws:codecommit:*:*:*"
}
]
}
# To restrict to a specific repo only, replace the Resource line with:
# "Resource": "arn:aws:codecommit:us-east-1:123456789012:my-backend-api"GetBranch / GetRepositoryResolve the default branch and latest commit IDGetFolder / GetFileWalk the file tree and fetch source file contentsCreateBranchCreate the fix branch (e.g. codescan/security-fixes-20260514)CreateCommitCommit all patched files atomically to the fix branchCreatePullRequestOpen the PR from the fix branch to your base branch2b. Generate the Access Key
- In IAM, click the user you just created
- Go to the Security credentials tab
- Scroll to Access keys and click Create access key
- Choose Application running outside AWS as the use case
- Click through to the confirmation page — you will see:Access key IDAKIAIOSFODNN7EXAMPLESecret access keywJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
- Copy both values immediately. AWS shows the secret key only once — it cannot be retrieved later. Paste them somewhere safe before closing.
Step 3 — Use the AWS tab in the CodeScan web scanner
3a. Open the Remote Repo panel
- Go to codesscan.com/scan and sign in
- In the left sidebar, click the ⎇ REMOTE REPO tab (next to ⬆ FILES)
- At the top of the panel you will see three provider chips — click AWS
3b. Fill in the fields
| Field | What to enter | Example |
|---|---|---|
| Repository name | Exact name from CodeCommit console (not the ARN) | my-backend-api |
| AWS Region | Region where the repo was created | us-east-1 |
| Access Key ID | IAM access key ID starting with AKIA | AKIAIOSFODNN7EXAMPLE |
| Secret Access Key | The secret key paired with the access key ID | wJalrXUtnFEMI/K7MDENG/… |
3c. Fetch & Scan
Click ⎇ Fetch & Scan. CodeScan will:
- Authenticate with AWS using your Access Key
- Resolve the default branch and latest commit ID
- Walk the repository folder tree recursively (up to 8 levels deep)
- Fetch each source file concurrently (up to 60 files by default)
- Run the full 5-step AI security pipeline on every file
- Run secret scanning in parallel (detects hardcoded API keys, tokens, passwords, certificates)
- Display results in the CODE FINDINGS, DEPENDENCIES, and SECRETS tabs
The sidebar confirms the fetch with the repo name, branch, and number of files loaded.
Step 4 — Review and apply fixes
Apply a fix to a single vulnerability
- In the CODE FINDINGS tab, click any file card to open the Detail view
- Click a vulnerability to expand its full description
- Click ⚡ Apply AI Fix — the fix is generated and applied to the file in the scanner
- Use the Show diff toggle to review exactly what changed
Use CodescanBot to apply fixes (conversational)
- Open CodescanBot (click ◈ CodescanBot in the header or press Ctrl+K)
- Select a vulnerability from the list
- Click the ⚡ Apply fix chip or type “fix this”
- The bot explains the change and applies it — the file updates automatically in the scanner
Step 5 — Create the Fix Pull Request
Once one or more files have been patched in the scanner, a green button appears in the sidebar:
- Click ⎇ Create Fix PR
- A modal opens. Confirm or edit:
- Branch name — default:
codescan/security-fixes-YYYYMMDD - PR title — default:
[CodeScan] Security fixes — N file(s) patched
- Branch name — default:
- Click ⎇ Create PR
- CodeScan creates the fix branch, commits all patched files in a single atomic
CreateCommitcall, and opens the PR - The PR URL appears in the sidebar — click it to open the diff in the AWS Console
What the PR looks like in the AWS Console
- Navigate to CodeCommit → Repositories → your-repo → Pull requests
- Source branch:
codescan/security-fixes-20260514 - Destination branch: your default branch (e.g.
main) - The description lists every patched file with a review checklist
- The Changes tab shows the exact diff — only vulnerable lines were modified
- Run your tests and CI pipeline, then approve and merge the PR normally
How the fix commit is built (technical detail)
CodeCommit's CreateCommit API accepts multiple file changes in a single call — all patches are applied atomically. The flow:
Step 6 — Using the CLI instead
The CLI gives you the same scan + fix + PR workflow from your terminal, ideal for CI/CD pipelines and automation scripts.
Install & login
npm install -g codescan-flowlog
codescan loginSet credentials as environment variables (recommended)
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
export AWS_REGION=us-east-1
# All codecommit commands now pick these up automaticallyScan a repo (read-only — nothing written to CodeCommit)
# Basic scan of the default branch
codescan codecommit scan my-backend-api
# Scan a specific branch
codescan codecommit scan my-backend-api --branch develop
# Show every finding (not just summary)
codescan codecommit scan my-backend-api --verbose
# Save full JSON report to file
codescan codecommit scan my-backend-api --output report.json
# Scan more than 60 files
codescan codecommit scan my-backend-api --max-files 120
# Pass credentials inline (without env vars)
codescan codecommit scan my-backend-api \
--access-key-id AKIAIOSFODNN7EXAMPLE \
--secret-access-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \
--region us-east-1Scan + fix + open PR (one command)
# Fix high+ severity findings and open PR
codescan codecommit fix my-backend-api
# Preview what would change (dry run — nothing written to AWS)
codescan codecommit fix my-backend-api --dry-run
# Fix only critical findings
codescan codecommit fix my-backend-api --severity critical
# Custom branch name and PR title
codescan codecommit fix my-backend-api \
--pr-branch security/q2-patches \
--pr-title "Security: patch SQL injection and hardcoded secrets — Sprint 18"
# Scan a non-default branch
codescan codecommit fix my-backend-api --branch stagingRecommended workflow
# 1. Dry run to preview what would change
codescan codecommit fix my-repo --dry-run
# 2. Review the output carefully, then apply for real
codescan codecommit fix my-repo
# 3. The PR URL is printed — open it in the AWS Console
# 4. Review the diff in the Changes tab
# 5. Run your tests, then approve and mergeCLI flag reference — codescan codecommit
| Flag | Env var | Default | Description |
|---|---|---|---|
| --access-key-id <key> | AWS_ACCESS_KEY_ID | — | IAM access key ID (starts with AKIA) |
| --secret-access-key <key> | AWS_SECRET_ACCESS_KEY | — | IAM secret access key paired with the ID above |
| --region <region> | AWS_REGION | — | AWS region where the CodeCommit repo lives |
| --branch <name> | — | default | Base branch to scan |
| --max-files <n> | — | 60 | Max source files to fetch |
| --severity <level> | — | high | Min severity to fix: critical | high | medium | low |
| --dry-run | — | false | Preview fixes without writing to CodeCommit |
| --pr-branch <name> | — | auto | Name for the fix branch |
| --pr-title <text> | — | auto | Pull request title |
| -v, --verbose | — | false | Show all per-file findings |
| --output <path> | — | — | Save JSON report to file (scan only) |
| -u, --url <url> | — | codesscan.com | Override CodeScan API base URL |
AWS CodeBuild — automated security scanning in CI/CD
Add CodeScan to your CodeBuild project so every commit to a monitored branch triggers a security scan. The build fails if critical vulnerabilities are found, blocking the merge.
# buildspec.yml
version: 0.2
env:
parameter-store:
CODESCAN_TOKEN: /codescan/token
phases:
install:
runtime-versions:
nodejs: 20
commands:
- npm install -g codescan-flowlog
build:
commands:
- codescan scan --dir ./src
--gate
--fail-on high
--save-history
--output codescan-report.json
artifacts:
files:
- codescan-report.jsonStore your CodeScan token in AWS Systems Manager Parameter Store as a SecureString under /codescan/token and grant the CodeBuild service role ssm:GetParameters access to that path.
Full pipeline with scan + auto-fix PR (CodePipeline)
# Add as a second CodeBuild action in your pipeline:
version: 0.2
env:
parameter-store:
CODESCAN_TOKEN: /codescan/token
AWS_ACCESS_KEY_ID: /codescan/aws-key-id
AWS_SECRET_ACCESS_KEY: /codescan/aws-secret
phases:
install:
runtime-versions:
nodejs: 20
commands:
- npm install -g codescan-flowlog
build:
commands:
# Fix critical/high findings and open a PR automatically
- codescan codecommit fix $REPO_NAME
--region $AWS_DEFAULT_REGION
--severity high
--pr-title "CodeScan automated fix — $CODEBUILD_BUILD_NUMBER"
--dry-run # remove --dry-run when you are ready to auto-mergeTroubleshooting
Quick reference cheatsheet
# ── Credentials (set once, reuse everywhere) ──────────────────────
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
export AWS_REGION=us-east-1
# ── Find your repo name ────────────────────────────────────────────
# AWS Console → Developer Tools → CodeCommit → Repositories → Name column
# ── Scan ──────────────────────────────────────────────────────────
codescan codecommit scan my-repo # default branch
codescan codecommit scan my-repo --branch develop # specific branch
codescan codecommit scan my-repo --verbose # all findings
codescan codecommit scan my-repo --output r.json # save report
# ── Fix + PR ──────────────────────────────────────────────────────
codescan codecommit fix my-repo # fix high+ → PR
codescan codecommit fix my-repo --dry-run # preview only
codescan codecommit fix my-repo --severity critical
codescan codecommit fix my-repo --pr-branch security/q2-fixes
# ── Web UI ────────────────────────────────────────────────────────
# codesscan.com/scan → ⎇ REMOTE REPO → AWS chip
# Enter: repo name + region + Access Key ID + Secret Access Key → Fetch & Scan