Skip to content

Commit

Permalink
pass repo ID to runconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeurbanski1 committed Jul 9, 2024
1 parent 82c8d8e commit f5af628
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion checkov/common/bridgecrew/platform_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ def get_platform_run_config(self) -> None:
self.get_public_run_config()

def _get_run_config_query_params(self) -> str:
return f'module={"bc" if self.is_bc_token(self.bc_api_key) else "pc"}&enforcementv2=true'
return f'module={"bc" if self.is_bc_token(self.bc_api_key) else "pc"}&enforcementv2=true&repoId={urllib.parse.quote(self.repo_id)}'

def get_run_config_url(self) -> str:
return f'{self.platform_run_config_url}?{self._get_run_config_query_params()}'
Expand Down
21 changes: 21 additions & 0 deletions tests/common/integration_features/test_repo_config_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,27 @@ def test_skip_paths_non_matching(self):
repo_config_integration._set_exclusion_paths(vcs_config)
self.assertEqual(repo_config_integration.skip_paths, set())

def test_skip_paths_no_repos(self):
vcs_config = {
"scannedFiles": {
"sections": [
{
"repos": [],
"rule": {
"excludePaths": []
},
"isDefault": True
}
]
}
}

instance = BcPlatformIntegration()
instance.repo_id = 'org/repo'
repo_config_integration = RepoConfigIntegration(instance)
repo_config_integration._set_exclusion_paths(vcs_config)
self.assertEqual(repo_config_integration.skip_paths, set())

def test_skip_paths_multiple_one_match(self):
vcs_config = {
"scannedFiles": {
Expand Down
7 changes: 5 additions & 2 deletions tests/common/test_platform_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,13 @@ def test_should_upload(self):

def test_run_config_url(self):
instance = BcPlatformIntegration()
instance.repo_id = 'owner/repo'
instance.bc_api_key = '00000000-0000-0000-0000-000000000000'
self.assertTrue(instance.get_run_config_url().endswith('/runConfiguration?module=bc&enforcementv2=true'))
self.assertTrue(instance.get_run_config_url().endswith('/runConfiguration?module=bc&enforcementv2=true&repoId=owner/repo'))
instance.bc_api_key = '00000000-0000-0000-0000-000000000000::1234=='
self.assertTrue(instance.get_run_config_url().endswith('/runConfiguration?module=pc&enforcementv2=true'))
self.assertTrue(instance.get_run_config_url().endswith('/runConfiguration?module=pc&enforcementv2=true&repoId=owner/repo'))
instance.repo_id = 'encode/më'
self.assertTrue(instance.get_run_config_url().endswith('/runConfiguration?module=pc&enforcementv2=true&repoId=encode/m%C3%AB'))

def test_is_valid_policy_filter(self):
instance = BcPlatformIntegration()
Expand Down

0 comments on commit f5af628

Please sign in to comment.