-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from advanced-security/v2_8
V2.8.0
- Loading branch information
Showing
18 changed files
with
468 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: "policy-as-code" | ||
version: "2.7.4" | ||
version: "2.8.0" | ||
|
||
locations: | ||
- name: "Update Docs" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# GHASToolkit Errors | ||
|
||
|
||
from typing import List, Optional | ||
|
||
|
||
class GHASToolkitError(Exception): | ||
"""Base class for GHASToolkit errors.""" | ||
|
||
def __init__( | ||
self, | ||
message: Optional[str] = None, | ||
docs: Optional[str] = None, | ||
permissions: Optional[List[str]] = [], | ||
status: Optional[int] = None, | ||
) -> None: | ||
self.message = message | ||
self.docs = docs | ||
self.permissions = permissions | ||
self.status = status | ||
|
||
super().__init__(message) | ||
|
||
def __str__(self) -> str: | ||
msg = "" | ||
|
||
if hasattr(self, "message"): | ||
msg = self.message | ||
else: | ||
msg = "An error occurred" | ||
|
||
if status := self.status: | ||
msg += f" (status code: {status})" | ||
|
||
if permissions := self.permissions: | ||
msg += "\n\nPermissions Required:" | ||
for perm in permissions: | ||
msg += f"\n- {perm}" | ||
if docs := self.docs: | ||
msg += f"\n\nFor more information, see: {docs}" | ||
|
||
return msg | ||
|
||
|
||
class GHASToolkitTypeError(GHASToolkitError): | ||
"""Raised when an invalid type is passed.""" | ||
|
||
|
||
class GHASToolkitAuthenticationError(GHASToolkitError): | ||
"""Raised when an authentication error occurs.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.