Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
telicent-validation-tool
Advanced tools
A library for validating data before it is brought in to Telicnt CORE.
A library for validating data before it is brought in to Telicent CORE.
pip install telicent-validation-tool
The JSON validator loads a json-schema from a given file path, and uses the jsonschema library to validate the provided JSON.
from telicent_validation_tool import TelicentValidationError, validate_json
my_json: str = '{"name: "John Smith"}'
schema_path: str = '/path/to/schema.json'
try:
validate_json(my_json, schema_path)
except TelicentValidationError as e:
print(f"Validation error: {e}")
The JSON schema file will only be loaded from disk on the first validation to improve the performance of subsequent validations.
To force a validation to reload the schema file from disk, set force_reload=True
.
validate_json(my_json, schema_path, force_reload=True)
The SHACL validator provides a wrapper around Telicent's own shacl-tool. It validates a rdf graph against the shacl and ontology triples of the base ontology being used and any domain specific extensions. For example, you might be using the FOAF base ontology but have extended some of the classes; for example:
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix myont: <http://example.com/ontology/my-domain-specific-ontology#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
myont:Child rdfs:subClassOf foaf:Person .
shacl_parts
and ontology_parts
are lists of paths to turtle files. This allows us to fuse shacl and ontology
files applicable to the graph requiring validation.
from rdflib import Graph, URIRef, Literal, XSD
from telicent_validation_tool import TelicentValidationError, validate_rdf_turtle
graph: Graph = Graph()
graph.add(
URIRef("http://example.com/data/nick_smith"),
URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
URIRef("http://example.com/ontology/my-domain-specific-ontology#Child")
)
graph.add(
URIRef("http://example.com/data/nick_smith"),
URIRef("http://xmlns.com/foaf/0.1/name"),
Literal("Nick Smith", datatype=XSD.string)
)
shacl_parts: list = [
'/path/to/foaf-base-ontology.shacl.ttl'
'/path/to/my-domain-specific.shacl.ttl'
]
ontology_parts: list = [
'/path/to/foaf-base-ontology.ttl'
'/path/to/my-domain-specific-ontology.ttl'
]
try:
validate_rdf_turtle(graph, shacl_parts, ontology_parts)
except TelicentValidationError as e:
print(f"Validation error: {e}")
FAQs
A library for validating data before it is brought in to Telicnt CORE.
We found that telicent-validation-tool 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.