Skip to content

Conversation

viralpoetry
Copy link

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Description

When external modules are pulled by using shortened version of the git hash, checkov fails to pull it and outputs:

2025-08-06 13:19:38,194 [MainThread  ] [WARNI]  failed to get git::https://github.com/rynkowsg/tf-modules?ref=f6a8868 in git loader because of Cmd('git') failed due to: exit code(128)                                                                      
  cmdline: git clone -v --depth=1 -b f6a8868 -- https://github.com/rynkowsg/tf-modules <my-repo-full-path>/.external_modules/github.com/rynkowsg/tf-modules/f6a8868                                                         
  stderr: 'Cloning into '<my-repo-full-path>/.external_modules/github.com/rynkowsg/tf-modules/f6a8868'...                                                                                                                   
POST git-upload-pack (356 bytes)                                                                                                                                                                                                                             
fatal: Remote branch f6a8868 not found in upstream origin

Fixes #7267

New/Edited policies (Delete if not relevant)

Description

Include a description of what makes it a violation and any relevant external links.

Fix

Change regex to accept shortened version of a commit hash

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • I have added tests that prove my feature, policy, or fix is effective and works
  • New and existing tests pass locally with my changes

@viralpoetry
Copy link
Author

@maxamel hi, I am using this change locally, it works for both shortened and full commit sha digests. It helped a lot on a huge ~7 years old terraform monorepo.

@maxamel
Copy link
Contributor

maxamel commented Oct 12, 2025

@viralpoetry thanks for the contribution, can you add a test for this?

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.

Checkov fails to download external modules when ref is a Git commit hash

2 participants