Skip to content

Commit c96986a

Browse files
committed
fix: remediate broken URLs, credentials, hardcoded account IDs, and stale Docker images
- Fix 119 issues across 63 files via repo consolidation pipeline - Replace old standalone repo URLs with consolidated paths - Replace exposed PATs with environment variable placeholders - Parameterize hardcoded AWS account IDs in ECR URLs - Replace hardcoded Docker image names with <IMAGE_NAME> placeholder - Add repo consolidation scan tool (tools/repo_consolidation/) - Add scheduled GitHub Actions workflow for weekly scans - Flag 5 private key files (.pem/.ppk) for manual review
1 parent f0c0e6e commit c96986a

96 files changed

Lines changed: 5056 additions & 185 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Repo Consolidation Scan
2+
3+
on:
4+
schedule:
5+
# Run every Monday at 08:00 UTC
6+
- cron: '0 8 * * 1'
7+
workflow_dispatch: # Allow manual trigger
8+
9+
permissions:
10+
contents: read
11+
issues: write
12+
13+
jobs:
14+
scan:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.12'
24+
25+
- name: Install dependencies
26+
run: pip install -r tools/requirements.txt
27+
28+
- name: Run consolidation scan (dry-run)
29+
id: scan
30+
run: |
31+
python -m tools.repo_consolidation DevOps-Projects \
32+
--dry-run \
33+
--report-output scan-report.txt \
34+
2>&1 | tee scan-output.log
35+
echo "exit_code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
36+
continue-on-error: true
37+
38+
- name: Upload scan report
39+
if: always()
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: scan-report
43+
path: |
44+
scan-report.txt
45+
scan-output.log
46+
47+
- name: Create issue if findings detected
48+
if: steps.scan.outputs.exit_code == '1'
49+
uses: actions/github-script@v7
50+
with:
51+
script: |
52+
const fs = require('fs');
53+
let report = '';
54+
try {
55+
report = fs.readFileSync('scan-report.txt', 'utf8');
56+
} catch (e) {
57+
report = 'Report file not found. Check workflow artifacts.';
58+
}
59+
60+
// Truncate if too long for an issue body
61+
if (report.length > 60000) {
62+
report = report.substring(0, 60000) + '\n\n... (truncated, see full report in artifacts)';
63+
}
64+
65+
const title = `[Automated] Repo consolidation scan found issues - ${new Date().toISOString().split('T')[0]}`;
66+
67+
// Check for existing open issue to avoid duplicates
68+
const existing = await github.rest.issues.listForRepo({
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
state: 'open',
72+
labels: 'repo-consolidation',
73+
per_page: 1,
74+
});
75+
76+
if (existing.data.length > 0) {
77+
// Update existing issue
78+
await github.rest.issues.createComment({
79+
owner: context.repo.owner,
80+
repo: context.repo.repo,
81+
issue_number: existing.data[0].number,
82+
body: `## Updated scan results\n\n\`\`\`\n${report}\n\`\`\``,
83+
});
84+
} else {
85+
// Create new issue
86+
await github.rest.issues.create({
87+
owner: context.repo.owner,
88+
repo: context.repo.repo,
89+
title: title,
90+
body: `## Repo Consolidation Scan Results\n\nThe scheduled scan detected issues that need attention.\n\n\`\`\`\n${report}\n\`\`\`\n\nRun \`python -m tools.repo_consolidation DevOps-Projects --dry-run\` locally to review.`,
91+
labels: ['repo-consolidation'],
92+
});
93+
}

β€Ž.gitignoreβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
IMPROVEMENTS.md
22
REVIEW-PLAN.md
33
REVIEW-UPDATES.md
4+
__pycache__/
5+
*.pyc

β€Žlearning/devops-101-track/PROJECT_7/README.mdβ€Ž

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@
8383

8484
#### 3 new environment variables ####
8585
registryCredential = 'ecr:us-east-1:awscreds'
86-
appRegistry = '392530415763.dkr.ecr.us-east-1.amazonaws.com/vprofileappimg'
87-
vprofileRegistry = "https://392530415763.dkr.ecr.us-east-1.amazonaws.com"
86+
# Replace <AWS_ACCOUNT_ID> with your AWS account ID
87+
appRegistry = '<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/<IMAGE_NAME>'
88+
# Replace <AWS_ACCOUNT_ID> with your AWS account ID
89+
vprofileRegistry = "https://<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com"
8890
################################
8991
stage('Build App image'){
9092
steps{

β€Žlearning/devops-bootcamp/docs/2-Github/2.5-Security.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Dependabot security updates are automatic pull requests that update your depende
4747

4848
## Exercise 1
4949

50-
To start off, we will explore a bit more of the code-scanning side of GitHub security using CodeQL. As mentioned previously, CodeQL has some good default workflows you can setup to help you get started with code-scanning. You can either use that or a tool we refactored into Go based off of [mario-campos/gh-code-scanning](https://github.com/mario-campos/gh-code-scanning) which does basically the same thing except its cooler and it lives [here](https://github.com/devcloudninjas/csgo) (still a work in progress).
50+
To start off, we will explore a bit more of the code-scanning side of GitHub security using CodeQL. As mentioned previously, CodeQL has some good default workflows you can setup to help you get started with code-scanning. You can either use that or a tool we refactored into Go based off of [mario-campos/gh-code-scanning](https://github.com/mario-campos/gh-code-scanning) which does basically the same thing except its cooler and it lives [here](learning/devops-bootcamp) (still a work in progress).
5151

5252
1. Create a repository that includes some code from one of the many CodeQl supported interpreted languages like Python or Javascript. A [RealWorld](https://github.com/khaledosman/react-redux-realworld-example-app) project is a good place to start since they are typically old and not maintained.
5353
2. Using the tool of your choice or just go through the basic workflow configuration, enable code-scanning on your repository as well as create a basic workflow to start doing some code scanning with.

β€Žlearning/devops-bootcamp/docs/3-virtual-machines-containers/3.3-managing-infrastructure.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Configure a self-hosted GitHub Action to deploy a build artifact to Nexus.
4747

4848
1. Create another clone of your Golden Image
4949
2. Install [Nexus](https://help.sonatype.com/repomanager3/installation-and-upgrades) into this clone
50-
3. In GitHub, fork the [spring-petclinic](https://github.com/devcloudninjas/spring-petclinic) project.
50+
3. In GitHub, fork the [spring-petclinic](learning/devops-bootcamp) project.
5151
4. In the GitHub portal, add a new self-hosted runner to your fork.
5252
5. Create another clone of your Golden Image
5353
6. Set up this clone as your self-hosted runner in the GitHub portal

β€Žlearning/devops-bootcamp/docs/4-cloud-computing/4.2.1-s3-cloudfront.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ In this section we will run through several exercises which showcase AWS S3 and
2828

2929
> Amazon Simple Storage Service (Amazon S3) is the largest and most performant, secure, and feature-rich object storage service. With Amazon S3, organizations of all sizes and industries can store any amount of data for any use case, including applications, IoT, data lakes, analytics, backup and restore, archive, and disaster recovery. -- [Amazon S3](https://aws.amazon.com/s3/)
3030
31-
For this exercise we're hosting a static HTML website using AWS S3. We will be using a simple react based application called [S3 Realworld UI DOB](https://github.com/devcloudninjas/s3-realworld-ui-dob) to create our sample website. Feel free to try creating and substituting with a different template or project.
31+
For this exercise we're hosting a static HTML website using AWS S3. We will be using a simple react based application called [S3 Realworld UI DOB](learning/devops-bootcamp) to create our sample website. Feel free to try creating and substituting with a different template or project.
3232

3333
**Requirements**
3434

β€Žlearning/devops-bootcamp/docs/4-cloud-computing/4.2.3-auto-scaling.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Read more about User Data in the [AWS documentation](https://docs.aws.amazon.com
5757

5858
## Exercise 1 - Create EC2 instance with User Data
5959

60-
In this exercise we will create an EC2 instance and use a User Data script to provision the instance as host for a Java web application. We recommend configuring a machine to run [Spring's PetClinic Project](https://github.com/devcloudninjas/spring-petclinic) on Amazon Linux 2023. But you are free to do this exercise with another web application and distro.
60+
In this exercise we will create an EC2 instance and use a User Data script to provision the instance as host for a Java web application. We recommend configuring a machine to run [Spring's PetClinic Project](learning/devops-bootcamp) on Amazon Linux 2023. But you are free to do this exercise with another web application and distro.
6161

6262
1. Create a script to pass into `--user-data`. In general the script needs to:
6363
- Install all dependencies for your web application

β€Žlearning/devops-bootcamp/docs/4-cloud-computing/4.2.6-ecs.mdβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Checkout this great explanation: [What is the difference between a task and serv
2828

2929
## Exercise
3030

31-
To get an understanding on how containers need to communicate with one another, we will be utilizing the [DevOps Knowledge Share UI](https://github.com/devcloudninjas/dks-ui) application we used before as well as the corresponding [API](https://github.com/devcloudninjas/dks-api).
31+
To get an understanding on how containers need to communicate with one another, we will be utilizing the [DevOps Knowledge Share UI](learning/devops-bootcamp) application we used before as well as the corresponding [API](learning/devops-bootcamp).
3232

3333
1. Start by taking the ui and api listed above and test them locally. Go though the `docker-compose.yaml` file to understand _what_ these microservices need.
3434
2. Then containerize them using Docker. (`make docker-build`)
@@ -40,7 +40,7 @@ To get an understanding on how containers need to communicate with one another,
4040

4141
7. Configure your cluster to run the application. Refer to the `docker-compose.yaml` files in `dks-ui` and `dks-api` to get a sense for what each service needs.
4242

43-
?> I recommend standing up your microservices in the following order validating each piece as you go: dks-db, dks-api, then dks-ui. See this example [task definition for dks-db](https://github.com/devcloudninjas/devops-bootcamp/blob/master/examples/ch4/aws/ecs/dks-db-task-definition.json) and the [db init script](https://github.com/devcloudninjas/dks-api/blob/6ee4e6aa87b62e4387d613cbd442863b60d07657/db-resources/0_0_db.sh).
43+
?> I recommend standing up your microservices in the following order validating each piece as you go: dks-db, dks-api, then dks-ui. See this example [task definition for dks-db](learning/devops-bootcamp/examples/ch4/aws/ecs/dks-db-task-definition.json) and the [db init script](learning/devops-bootcamp/db-resources/0_0_db.sh).
4444

4545
?> To interconnect services look into [AWS Service Discovery](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/interconnecting-services.html). Managing Service Discovery Namespaces and Services is simpler via the awscli. See the [following for reference](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-service-discovery.html#create-service-discovery-namespace). The Service Discovery Namespace name and the Service Discovery Service name will control the resulting DNS record. This will also dictate what you set for DB_HOST environment variable for the dks-api.
4646

β€Žlearning/devops-bootcamp/docs/4-cloud-computing/4.2.7-eks.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ In the previous section, we launch the SockShop demo on an ECS cluster to demons
164164

165165
?> Hint: Creating a temporary Node Group without providing a launch template will automatically create a launch template, whose configurations can be analyzed and applied to your own.
166166

167-
6. Launch SockShop application on your cluster using the `deploy/kubernetes/complete-demo.yaml` in the [microservice-demo](https://github.com/devcloudninjas/microservices-demo) repo.
167+
6. Launch SockShop application on your cluster using the `deploy/kubernetes/complete-demo.yaml` in the [microservice-demo](learning/devops-bootcamp) repo.
168168

169169
?> Depending on the version of Kubernetes you select when creating your EKS cluster, the `complete-demo.yaml` may need to be updated
170170

β€Žlearning/devops-bootcamp/docs/4-cloud-computing/4.3.7-app-service.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Azure App Service is a fully managed platform for building, deploying, and scali
2222

2323
We will be using DevCloudNinjas' version of the spring-petclinic for this exercise, it's a simple java application that deploys a web app for a virtual pet clinic.
2424

25-
1. Fork [Spring-Petclinic](https://github.com/devcloudninjas/spring-petclinic.git). (We will be using this later for Continuous Deployment)
25+
1. Fork [Spring-Petclinic](learning/devops-bootcamp/.git). (We will be using this later for Continuous Deployment)
2626

2727
2. Clone your new fork.
2828

0 commit comments

Comments
Β (0)