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

modify env var passed to ggshield to get number of commits in push event #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amascia-gg
Copy link

The base_revision has many issues and can't be relied on to get the commit range.
The proposed solution is to fetch the number of commits included in the push event in order to list the commits to scan.

src/@orb.yml Outdated Show resolved Hide resolved
src/@orb.yml Outdated Show resolved Hide resolved
src/@orb.yml Outdated
@@ -50,7 +55,8 @@ jobs:
docker:
- image: gitguardian/ggshield:<<parameters.tag>>
environment:
CIRCLE_RANGE: <<parameters.base_revision>>...<<parameters.revision>>
NUMBER_COMMITS_GH: <<parameters.number_commits_gh>>
NUMBER_COMMITS_GL: <<parameters.number_commits_gl>>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would have been nice to expose only one variable, but I assume it's not possible to do operations like max or + here?

Copy link
Author

Choose a reason for hiding this comment

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

It seems possible if I do something like

GITHUB_COUNT="<<pipeline.trigger_parameters.github_app.total_commits_count>>"
GITLAB_COUNT="<<pipeline.trigger_parameters.gitlab.total_commits_count>>"
MAX_COUNT=$(( GITHUB_COUNT > GITLAB_COUNT ? GITHUB_COUNT : GITLAB_COUNT ))
echo "export CIRCLE_COMMIT_COUNT=$MAX_COUNT" >> $BASH_ENV

In run, before the ggshield secret scan command

Do you think it's worth it ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a bit hackish, but that is what happens with shell scripting :). I think it's worth it because it means we don't have to make a new ggshield release if we ever find a way to get the BitBucket count, or whatever ci-host-of-the-day is added to CircleCI in the future.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @agateau-gg, I am tackling this issue since I have some time now but I am really struggling to make this work.
I've tried a lot of solutions (you can see them in the commits of this branch) but I can't find a way to fetch both values (for GitHub and GitLab). Can we have a look together if you have some time please?

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.

None yet

2 participants