Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
PA-10432-2 Try to access each env variable (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
SOOS-JAlvarez committed Aug 10, 2023
1 parent 610910a commit 8cdc0d0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cli/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.12-rc1
1.7.12-rc2
34 changes: 34 additions & 0 deletions src/cli/soos.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
MAX_MANIFESTS = 50
SCAN_STATUS_ERROR = "Error"
SCAN_STATUS_INCOMPLETE = "Incomplete"
CONTRIBUTING_DEVELOPER = "unknown"

with open(os.path.join(os.path.dirname(__file__), "VERSION.txt")) as version_file:
SCRIPT_VERSION = version_file.read().strip()
Expand Down Expand Up @@ -64,6 +65,30 @@ class PackageManager(Enum):
RUBY= "Ruby",
RUST="Rust"

class IntegrationName(Enum):
CODEBUILD = "AWSCodeBuild"
BAMBOO = "Bamboo"
BITBUCKET = "BitBucket"
CIRCLECI = "CircleCI"
CODE_SHIP = "CodeShip"
GITHUB_ACTIONS = "GitHub"
GITLAB = "GitLab"
JENKINS = "Jenkins"
TEAMCITY = "TeamCity"
TRAVIS = "TravisCI"

class ContributorVariableNames(Enum):
AWSCodeBuild = "CODEBUILD_BUILD_INITIATOR"
Bamboo = "bamboo_planRepository_1_username"
BitBucket = "BITBUCKET_STEP_TRIGGERER_UUID"
CircleCI = "CIRCLE_USERNAME"
CodeShip = "CI_COMMITTER_USERNAME"
GitHub = "GITHUB_ACTOR"
GitLab = "GITLAB_USER_LOGIN"
Jenkins = "CHANGE_AUTHOR"
TeamCity = "teamcity.build.triggeredBy.username"
TravisCI = "TRAVIS_COMMIT"

class ErrorAPIResponse:
code: Optional[str] = None
message: Optional[str] = None
Expand Down Expand Up @@ -564,6 +589,15 @@ def create_scan_metadata(context: SOOSContext) -> Union[CreateScanAPIResponse, E
set_body_value(start_scan_data, 'integrationName', context.integration_name)
set_body_value(start_scan_data, 'appVersion', context.app_version)

if context.integration_name is not None:
integration_name_enum = next(
(item for item in IntegrationName if item.value == context.integration_name), None)

if integration_name_enum: # Check if we found a match in IntegrationName
integration_variable_name = ContributorVariableNames[integration_name_enum.value].value
integration_variable_value = os.environ.get(integration_variable_name)
context.contributing_developer = integration_variable_value

if context.contributing_developer is not None:
start_scan_data['contributingDeveloperAudit'] = [{
"source": "EnvironmentVariable",
Expand Down

0 comments on commit 8cdc0d0

Please sign in to comment.