-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bringing back @DarthHater work on JSF signatures #146
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8acf98a
WIP but a lil hand up for @madpah
DarthHater 4edcb0e
chore: added missing license header
madpah cbebae2
No default values for required fields
DarthHater 0f2d681
Add Services to BOM
DarthHater 756218d
Typo fix
DarthHater 42a7ae7
aligned classes with standards, commented out Signature work for now,…
madpah 72c3af4
Merged in work from @DarthHater
madpah 33a26d8
Bringing back @DarthHater work on JSF signatures
madpah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -51,6 +51,185 @@ def sha1sum(filename: str) -> str: | |
return h.hexdigest() | ||
|
||
|
||
class DataFlow(Enum): | ||
""" | ||
This is our internal representation of the dataFlowType simple type within the CycloneDX standard. | ||
|
||
.. note:: | ||
See the CycloneDX Schema: https://cyclonedx.org/docs/1.4/xml/#type_dataFlowType | ||
""" | ||
INBOUND = "inbound" | ||
OUTBOUND = "outbound" | ||
BI_DIRECTIONAL = "bi-directional" | ||
UNKNOWN = "unknown" | ||
|
||
|
||
class DataClassification: | ||
""" | ||
This is our internal representation of the `dataClassificationType` complex type within the CycloneDX standard. | ||
|
||
.. note:: | ||
See the CycloneDX Schema for dataClassificationType: | ||
https://cyclonedx.org/docs/1.4/xml/#type_dataClassificationType | ||
""" | ||
|
||
def __init__(self, flow: DataFlow, classification: str) -> None: | ||
if not flow and not classification: | ||
raise NoPropertiesProvidedException( | ||
'One of `flow` or `classification` must be supplied - neither supplied' | ||
) | ||
|
||
self.flow = flow | ||
self.classification = classification | ||
|
||
@property | ||
def flow(self) -> DataFlow: | ||
""" | ||
Specifies the flow direction of the data. | ||
|
||
Valid values are: inbound, outbound, bi-directional, and unknown. | ||
|
||
Direction is relative to the service. | ||
|
||
- Inbound flow states that data enters the service | ||
- Outbound flow states that data leaves the service | ||
- Bi-directional states that data flows both ways | ||
- Unknown states that the direction is not known | ||
|
||
Returns: | ||
`DataFlow` | ||
""" | ||
return self._flow | ||
|
||
@flow.setter | ||
def flow(self, flow: DataFlow) -> None: | ||
self._flow = flow | ||
|
||
@property | ||
def classification(self) -> str: | ||
""" | ||
Data classification tags data according to its type, sensitivity, and value if altered, stolen, or destroyed. | ||
|
||
Returns: | ||
`str` | ||
""" | ||
return self._classification | ||
|
||
@classification.setter | ||
def classification(self, classification: str) -> None: | ||
self._classification = classification | ||
|
||
|
||
class SignatureAlgorithm(Enum): | ||
""" | ||
This is out internal representation of the algorithm simple type within the CycloneDX standard. | ||
|
||
.. note:: | ||
See the CycloneDX Schema: https://cyclonedx.org/docs/1.4/json/#tab-pane_signature_oneOf_i2_algorithm_oneOf_i0 | ||
""" | ||
RS256 = "RS256" | ||
RS384 = "RS384" | ||
RS512 = "RS512" | ||
PS256 = "PS256" | ||
PS384 = "PS384" | ||
PS512 = "PS512" | ||
ES256 = "ES256" | ||
ES384 = "ES384" | ||
ES512 = "ES512" | ||
ED25519 = "Ed25519" | ||
ED448 = "Ed448" | ||
HS256 = "HS256" | ||
HS384 = "HS384" | ||
HS512 = "HS512" | ||
|
||
|
||
class SignaturePublicKeyKty(Enum): | ||
""" | ||
This is our internal representation of the kty simple type within the CycloneDX standard. | ||
|
||
.. note:: | ||
See the CycloneDX Schema: https://cyclonedx.org/docs/1.4/json/#signature_oneOf_i2_publicKey_kty | ||
""" | ||
EC = "EC" | ||
OKP = "OKP" | ||
RSA = "RSA" | ||
|
||
|
||
class SignaturePublicKeyCrv(Enum): | ||
""" | ||
This is our internal representation of the crv simple type within the CycloneDX standard. | ||
|
||
.. note:: | ||
See the CycloneDX Schema: https://cyclonedx.org/docs/1.4/json/#signature_oneOf_i2_publicKey_allOf_i1_then_crv | ||
""" | ||
ED25519 = "Ed25519" | ||
Ed448 = "Ed448" | ||
|
||
|
||
class SignaturePublicKey: | ||
""" | ||
This is our internal representation of the public key complex type within the CycloneDX standard. | ||
|
||
.. note:: | ||
See the CycloneDX Schema: https://cyclonedx.org/docs/1.4/json/#signature_oneOf_i2_publicKey | ||
JSON only | ||
""" | ||
|
||
def __init__(self, kty: SignaturePublicKeyKty = None, crv: Optional[SignaturePublicKeyCrv] = None, | ||
x: Optional[str] = None, y: Optional[str] = None, | ||
n: Optional[str] = None, e: Optional[str] = None, | ||
value: str = None) -> None: | ||
if not kty and not value: | ||
raise NoPropertiesProvidedException( | ||
'`kty` must be supplied' | ||
) | ||
if kty == SignaturePublicKeyKty.EC and not crv and not x and not y: | ||
raise NoPropertiesProvidedException( | ||
'if `kty` equals EC, `crv`, `x` and `y` must be supplied' | ||
) | ||
if kty == SignaturePublicKeyKty.OKP and not crv and not x: | ||
raise NoPropertiesProvidedException( | ||
'if `kty` equals OKP, `crv`, and `x` must be supplied' | ||
) | ||
if kty == SignaturePublicKeyKty.RSA and not n and not e: | ||
raise NoPropertiesProvidedException( | ||
'if `kty` equals RSA, `n`, and `e` must be supplied' | ||
) | ||
self.kty = kty | ||
self.crv = crv | ||
self.x = x | ||
self.y = y | ||
self.n = n | ||
self.e = e | ||
self.value = value | ||
|
||
|
||
class Signature: | ||
""" | ||
This is out internal representation of the signature complex type within the CycloneDX standard. | ||
|
||
.. note:: | ||
See the CycloneDX Schema: https://cyclonedx.org/docs/1.4/json/#signature | ||
JSON only | ||
""" | ||
|
||
def __init__(self, algorithm: SignatureAlgorithm, key_id: Optional[str], | ||
public_key: Optional[SignaturePublicKey] = None, | ||
certificate_path: Optional[List[str]] = None, | ||
excludes: Optional[List[str]] = None, | ||
value: str = None) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incompatible variable type: value is declared to have type |
||
if not algorithm and not value: | ||
raise NoPropertiesProvidedException( | ||
'One of `algorithm` or `value` must be supplied - neither supplied' | ||
) | ||
self.algorithm = algorithm | ||
self.key_id = key_id | ||
self.public_key = public_key | ||
self.certificate_path = certificate_path | ||
self.excludes = excludes | ||
self.value = value | ||
|
||
|
||
class Encoding(Enum): | ||
""" | ||
This is out internal representation of the encoding simple type within the CycloneDX standard. | ||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incompatible variable type: kty is declared to have type
SignaturePublicKeyKty
but is used as typeNone
.(at-me in a reply with
help
orignore
)