Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add workflow for dependency-track #1654

Merged
merged 2 commits into from
Feb 3, 2025

Conversation

martinakraus
Copy link
Contributor

Implements SEC-60


Key features

  1. Integration of Static Analysis Security Scanning Tool: Dependency Track: https://dtrack.security.dhis2.org/projects
  2. Running every night so it won't bother Developers

Description

Dependency Track will scan the created SBOM and analyze for CVEs and open vulnerabilities.
Those reports will be evaluated by the security team and will be brought back to the dev teams if something crucial pops up


@martinakraus martinakraus requested a review from a team as a code owner January 7, 2025 12:10
@dhis2-bot
Copy link
Contributor

dhis2-bot commented Jan 7, 2025

🚀 Deployed on https://pr-1654--dhis2-ui.netlify.app

@dhis2-bot dhis2-bot temporarily deployed to netlify January 7, 2025 12:14 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify January 7, 2025 12:31 Inactive
@martinakraus martinakraus force-pushed the feat/integrate-dependecy-track branch from ee4fd80 to 0fb7ac7 Compare January 7, 2025 12:56
@dhis2-bot dhis2-bot temporarily deployed to netlify January 7, 2025 12:59 Inactive
Copy link
Member

@amcgee amcgee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good! Added a few comments.

It would also probably be a good idea to move this to a shared workflow (see https://github.com/dhis2/workflows-platform) and then refer to it from any repositories where we want to track the BOM

Comment on lines 28 to 32
- name: Install CycloneDX CLI
run: |
curl -s https://api.github.com/repos/CycloneDX/cyclonedx-cli/releases/latest | grep "browser_download_url.*linux.x64" | cut -d '"' -f 4 | wget -i -
sudo mv cyclonedx-linux-x64 /usr/local/bin/
sudo chmod +x /usr/local/bin/cyclonedx-linux-x64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinakraus is the downloading of this binary necessary since we install cdxgen using npm in the next step..?

It seems to me that we should prefer npm install, as they do in this CycloneDX github action (though using a slightly different tool, the goal of creating a node_modules BOM looks the same...) https://github.com/CycloneDX/gh-node-module-generatebom/blob/master/index.js#L28

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have two repositories for shared workflows, https://github.com/dhis2/workflows (not necessarily reusable workflows) and https://github.com/dhis2/workflows-platform where we currently keep reusable workflows that apply across most of our apps

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amcgee I would love to do both. But there are two issues:
https://www.npmjs.com/package/%40cyclonedx/yarn-plugin-cyclonedx is used for creating SBOMS with CycloneDX github action. This required Yarn > 3.
There are some frontend repos (for example dashboard-app which are still on Yarn 1.2.2
So in order to move it to a common Workflow Repo and use this Workflow everywhere, I believe a common Yarn version is required.
Or I can use the CycloneDX Github action at least justin those frontend Repos which are at least on Yarn version 3

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only support yarn v1 for the moment, so there won't be any repos that have yarn v3 unfortunately.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still seems that the binrary download here isn't necessary though right? Or is that a prerequisite for npm install -g @cyclonedx/cdxgen in the next step? Otherwise I'm not sure where this downloaded binary executable is being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much @amcgee you are absolutely right - this was totally unused.
The CycloneDX CLI can be used to merge SBOMs together in one - I have used it for dhis2-core. There I have created a SBOM for each project and in the enc I merged them in one SBOM.
But not necessary at all here - this was just copy + paste confusion. Sorry for that!

Comment on lines 25 to 26
- uses: c-hive/gha-yarn-cache@v1
- run: yarn install --frozen-lockfile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably fine, and likely comes from some of our other actions in this repository. We don't use this in our more modern standard repos, though, so might not be necessary to have this dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me. Is there some docs about the configuration about the 'modern standard repos'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I removed the c-hive/gha-yarn-cache@v1 Workflow as well :)

--fail-with-body \
-H "Content-Type: multipart/form-data" \
-H "X-Api-Key: ${{ secrets.DEPENDENCYTRACK_APIKEY }}" \
-F "project=53c6ea2f-413f-45b9-a360-e366f917277d" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we make this project ID a repository variable we can extract this whole workflow and call it from individual repositories - see for example https://github.com/dhis2/route-manager-app/blob/main/.github/workflows/comment-and-close.yml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree and would love that but please find my considerations above (regarding Yarn version)

Comment on lines 28 to 32
- name: Install CycloneDX CLI
run: |
curl -s https://api.github.com/repos/CycloneDX/cyclonedx-cli/releases/latest | grep "browser_download_url.*linux.x64" | cut -d '"' -f 4 | wget -i -
sudo mv cyclonedx-linux-x64 /usr/local/bin/
sudo chmod +x /usr/local/bin/cyclonedx-linux-x64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have two repositories for shared workflows, https://github.com/dhis2/workflows (not necessarily reusable workflows) and https://github.com/dhis2/workflows-platform where we currently keep reusable workflows that apply across most of our apps

Comment on lines +35 to +31
npm install -g @cyclonedx/cdxgen
cdxgen -o sbom.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(minor) Technically I think this could be just npx @cyclonedx/cdxgen -o sbom.json, so you don't need to install anything globally

@martinakraus martinakraus force-pushed the feat/integrate-dependecy-track branch from 0fb7ac7 to 686f333 Compare January 28, 2025 19:17
@dhis2-bot dhis2-bot temporarily deployed to netlify January 28, 2025 19:21 Inactive
@martinakraus martinakraus force-pushed the feat/integrate-dependecy-track branch from 686f333 to ad1bae8 Compare January 28, 2025 19:22
@dhis2-bot dhis2-bot temporarily deployed to netlify January 28, 2025 19:26 Inactive
@martinakraus martinakraus force-pushed the feat/integrate-dependecy-track branch from ad1bae8 to 1d513a0 Compare January 28, 2025 19:44
@dhis2-bot dhis2-bot temporarily deployed to netlify January 28, 2025 19:48 Inactive
Copy link
Member

@amcgee amcgee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@amcgee amcgee merged commit e7b3eb0 into master Feb 3, 2025
18 checks passed
@amcgee amcgee deleted the feat/integrate-dependecy-track branch February 3, 2025 15:02
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 10.1.11 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants