Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
This package helps you in generating ontology-related objects and let's you easily create JSON-LD files.
Install the package:
pip install ontolutils
Imagine you want to describe a prov:Person
with a first name, last name and an email address but writing
the JSON-LD file yourself is too cumbersome and you want validation of the parsed parameters. The package
lets you design classes, which describe ontology classes like this:
from pydantic import EmailStr, Field
from pydantic import HttpUrl, model_validator
from ontolutils import Thing, urirefs, namespaces, as_id
@namespaces(prov="https://www.w3.org/ns/prov#",
foaf="https://xmlns.com/foaf/0.1/",
m4i='http://w3id.org/nfdi4ing/metadata4ing#')
@urirefs(Person='prov:Person',
firstName='foaf:firstName',
last_name='foaf:lastName',
mbox='foaf:mbox',
orcidId='m4i:orcidId')
class Person(Thing):
firstName: str
lastName: str = Field(default=None, alias="last_name") # you may provide an alias
mbox: EmailStr = Field(default=None, alias="email")
orcidId: HttpUrl = Field(default=None, alias="orcid_id")
# the following will ensure, that if orcidId is set, it will be used as the id
@model_validator(mode="before")
def _change_id(self):
return as_id(self, "orcidId")
p = Person(id="https://orcid.org/0000-0001-8729-0482",
firstName='Matthias', last_name='Probst')
# as we have set an alias, we can also use "lastName":
p = Person(id="https://orcid.org/0000-0001-8729-0482",
firstName='Matthias', lastName='Probst')
# The jsonld representation of the object will be the same in both cases:
p.model_dump_jsonld()
Now, you can instantiate the class and use the model_dump_jsonld()
method to get a JSON-LD string:
{
"@context": {
"owl": "https://www.w3.org/2002/07/owl#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"prov": "https://www.w3.org/ns/prov#",
"foaf": "https://xmlns.com/foaf/0.1/"
},
"@id": "https://orcid.org/0000-0001-8729-0482",
"@type": "prov:Person",
"foaf:firstName": "Matthias",
"foaf:lastName": "Probst"
}
Please visit the documentation for more information.
FAQs
Utility library for the work with ontologies.
We found that ontolutils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.