display_relationship_graph_legend()
SPDX Type | Node Color | |
---|---|---|
0 | File | Yellow |
1 | Package | Blue |
2 | SPDXDocument | Red |
This page defines all boilerplate functions to be used when analyzing sboms. To see these functions in action please view the following pages.
Many of the queries seen on this page were written with the help of ChatGPT. To repeat this simply prompt ChatGPT as follows: Write me a SPARQL query to select X, Y, and Z
These functions perform basic queries and return metadata about a given knowledge graph
show_metadata (kg:kglab.kglab.KnowledgeGraph, dataframe:bool=False)
Return total number of triples, distict entities, and properties to a pandas dataframe.
Type | Default | Details | |
---|---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from | |
dataframe | bool | False | Optionally, return result to dataframe |
show_entity_types (kg:kglab.kglab.KnowledgeGraph, dataframe:bool=False)
Show counts of entity types
Type | Default | Details | |
---|---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from | |
dataframe | bool | False | Optionally, return result to dataframe |
show_top_n_props (kg:kglab.kglab.KnowledgeGraph, n:int=10, dataframe:bool=False)
Display the top N properties from a knowledge graph
Type | Default | Details | |
---|---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from | |
n | int | 10 | Top n results to display |
dataframe | bool | False | Optionally, return result to dataframe |
show_measures (kg:kglab.kglab.KnowledgeGraph)
Display number of nodes and edges for knowledge graph
Type | Details | |
---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from |
These functions peform queries on a SBOM’s files
file_schema (kg:kglab.kglab.KnowledgeGraph)
Display all properties for a file
Type | Details | |
---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from |
get_files_data (kg:kglab.kglab.KnowledgeGraph)
Return all files and their properties
Type | Details | |
---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from |
Returns | DataFrame | Return result to dataframe |
get_files_graph (kg:kglab.kglab.KnowledgeGraph)
Return a subgraph of the files and their properties
Type | Details | |
---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from |
Returns | KnowledgeGraph | Return result to knowledge graph |
package_schema (kg:kglab.kglab.KnowledgeGraph)
Return the schema for the package
Type | Details | |
---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from |
Returns | DataFrame | Return result to dataframe |
get_package_data (kg:kglab.kglab.KnowledgeGraph)
Construct a dataframe of package data
Type | Details | |
---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from |
Returns | DataFrame | Return result to dataframe |
get_package_graph (kg:kglab.kglab.KnowledgeGraph)
Construct a subgraph of the package data
Type | Details | |
---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from |
Returns | KnowledgeGraph | Return result to knowledge graph |
relationship_schema (kg:kglab.kglab.KnowledgeGraph)
Return the schema for the relationships
Type | Details | |
---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from |
Returns | DataFrame | Return result to dataframe |
get_relationship_data (kg:kglab.kglab.KnowledgeGraph)
Type | Details | |
---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from |
Returns | DataFrame | Return result to dataframe |
get_relationship_graph (kg:kglab.kglab.KnowledgeGraph)
Construct a subgraph of the relationship data
Type | Details | |
---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from |
Returns | KnowledgeGraph | Return result to knowledge graph |
sbomqs_scores (sbomqs_dir:str)
Create DataFrame with quality scores for the SBOM generation tools.
Type | Details | |
---|---|---|
sbomqs_dir | str | Directory for the json files generated by the sbomqs tool |
Returns | typing.Tuple[pandas.core.frame.DataFrame, pandas.core.frame.DataFrame] | Return two DataFrames, one with the information about each file in sbomqs_dir and another with scores for each feature in the SBOM quality categories for all files |
sbomqs_score_by_cat (feature_qscores:pandas.core.frame.DataFrame)
Create a DataFrame with the average score by category for each SBOM generation tool
Type | Details | |
---|---|---|
feature_qscores | DataFrame | It is a DataFrame with the quality scores for each feature in each category for all tools. |
Returns | DataFrame | Return a DataFrame with the average scores by categories for the SBOM generation tools. |
Functions to visualize graph results
visualize_graph (kg:kglab.kglab.KnowledgeGraph, VIS_STYLE:str={})
Visualize the knowledge graph
Type | Default | Details | |
---|---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from | |
VIS_STYLE | str | {} | Optional, visualization style |
visualize_relationship_graph (kg:kglab.kglab.KnowledgeGraph, hideTypeFile:str=False)
Construct a Network object for representing the SBOMs components relationship graph. The returned graph is ready to be visualized using .show()
.
Type | Default | Details | |
---|---|---|---|
kg | KnowledgeGraph | Knowledge graph to query from | |
hideTypeFile | str | False | Flag for showing SPDX:File type components in the graph |
Returns | Network | Return a Network object representing the SBOMs relationship graph |
display_relationship_graph_legend ()
Display the legend of the SBOMs components relationship graph that can be visualized by visualize_relationship_graph()
.
SPDX Type | Node Color | |
---|---|---|
0 | File | Yellow |
1 | Package | Blue |
2 | SPDXDocument | Red |
display_qscores_with_descriptions (feature_qscores:pandas.core.frame.Dat aFrame, category_list:list=None, tool_list:list=None)
Type | Default | Details | |
---|---|---|---|
feature_qscores | DataFrame | DataFrame with the quality scores for each feature in each category for all tools. | |
category_list | list | None | List of categories to be displayed. If None, all categories are displayed. |
tool_list | list | None | List of tools to be displayed. If None, all tools are displayed. |
Returns | None |
display_category_qscores_heatmap (feature_qscores:pandas.core.frame.Data Frame, category_list:list=None)
This function displays a heatmap for each SBOM quality category showing scores by tools for each category feature.
Type | Default | Details | |
---|---|---|---|
feature_qscores | DataFrame | DataFrame with the quality scores for each feature in each category for all tools. | |
category_list | list | None | List of categories to be displayed. If None, all categories are displayed. |
Returns | None |
display_qscores_heatmap (feature_qscores)
This function display a heatmap showing scores by tools for each SBOM quality category.
Type | Details | |
---|---|---|
feature_qscores | DataFrame with the quality scores for each feature in each category for all tools. | |
Returns | None |
sbomqs_radar_chart (feature_qscores)
Construct a radar chart for the quality scores of the SBOMs categories for each tool.
Type | Details | |
---|---|---|
feature_qscores | DataFrame with the quality scores for each feature in each category for all tools. | |
Returns | None |