Skip to content

Commit

Permalink
fix(github): changed the schema to accept no description for org (#3589)
Browse files Browse the repository at this point in the history
* changed the schema to accept no desription for org

* added a test

* changed test
  • Loading branch information
marynaKK authored Oct 2, 2022
1 parent f3a6970 commit edd25ee
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
5 changes: 4 additions & 1 deletion checkov/github/schemas/org_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def __init__(self) -> None:
"type": "string"
},
"description": {
"type": "string"
"oneOf": [
{"type": "string"},
{"type": "null"}
]
},
"ipAllowListEnabledSetting": {
"type": "string"
Expand Down
24 changes: 22 additions & 2 deletions tests/github/test_dal.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@


@mock.patch.dict(os.environ, {"GITHUB_ORG": "simpleOrg"}, clear=True)
def test_org_security(mocker: MockerFixture):
def test_org_security_null_description(mocker: MockerFixture):
dal = Github()
mock_data = {
"data": {
"organization": {
"name": "Bridgecrew",
"login": "Bridgecrew-dev",
"description": "",
"description": None,
"ipAllowListEnabledSetting": "DISABLED",
"ipAllowListForInstalledAppsEnabledSetting": "DISABLED",
"requiresTwoFactorAuthentication": False,
Expand All @@ -26,6 +26,26 @@ def test_org_security(mocker: MockerFixture):
result = dal.get_organization_security()
assert result

@mock.patch.dict(os.environ, {"GITHUB_ORG": "simpleOrg"}, clear=True)
def test_org_security_str_description(mocker: MockerFixture):
dal = Github()
mock_data2 = {
"data": {
"organization": {
"name": "Bridgecrew",
"login": "Bridgecrew-dev",
"description": "",
"ipAllowListEnabledSetting": "DISABLED",
"ipAllowListForInstalledAppsEnabledSetting": "DISABLED",
"requiresTwoFactorAuthentication": False,
"samlIdentityProvider": None
}
}
}
mocker.patch("checkov.common.vcs.base_vcs_dal.BaseVCSDAL._request_graphql", return_value=mock_data2)
result = dal.get_organization_security()
assert result


def test_validate_github_conf_paths():
dal = Github()
Expand Down

0 comments on commit edd25ee

Please sign in to comment.