Skip to content

Instantly share code, notes, and snippets.

@ioggstream
Created May 30, 2022 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ioggstream/31f3226fa9976b3baf0800f44bc19c98 to your computer and use it in GitHub Desktop.
Save ioggstream/31f3226fa9976b3baf0800f44bc19c98 to your computer and use it in GitHub Desktop.
Show anchor usage
from rdflib import Graph
import yaml
d = yaml.safe_load(Path("d3fend.yaml").read_text())
g=Graph()
g.parse(data=json.dumps(d), format="application/ld+json")
print(g.serialize(format="application/ld+json"))
---
"@context":
"@vocab": &d3fend "http://d3fend.mitre.org/ontologies/d3fend.owl#"
"@base": *d3fend
owl: "http://www.w3.org/2002/07/owl#"
rdfs: "http://www.w3.org/2000/01/rdf-schema#"
"@graph":
- '@id': ApplicationHardening
'@type': &defensiveTechniqueClassess # Anchor this list
- DefensiveTechnique
- owl:Class
- owl:NamedIndividual
d3fend-id:
- '@value': D3-AH
definition:
- '@value': |-
Application Hardening makes an executable application more resilient
to a class of exploits which either introduce new code or execute unwanted existing
code. These techniques may be applied at compile-time or on an application binary.
enables:
- &harden # Anchor this object
'@id': Harden
rdfs:label:
- '@value': Application Hardening
rdfs:subClassOf:
- '@id': DefensiveTechnique
- &enables-harden-restriction
'@type':
- owl:Restriction
owl:onProperty:
- '@id': enables
owl:someValuesFrom:
- *harden
- '@id': :PlatformHardening
'@type': *defensiveTechniqueClassess # reference to the above list
d3fend-id:
- '@value': D3-PH
definition:
- '@value': Platform Hardening ...
enables:
- *harden
rdfs:label:
- '@value': Platform Hardening
rdfs:subClassOf:
- '@id': DefensiveTechnique
- *enables-harden-restriction # Reference anchor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment