-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fill in RTD site getting started, usage, configuration, and plugin pa…
…ge TODOs (#82) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ryan Mast <[email protected]>
- Loading branch information
1 parent
999eca7
commit dc2f90f
Showing
4 changed files
with
303 additions
and
14 deletions.
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
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 |
---|---|---|
|
@@ -2,18 +2,60 @@ | |
|
||
## Installation | ||
|
||
TODO: Installation steps | ||
### For Users: | ||
|
||
1. Create a virtual environment with python >= 3.8 [Optional, but recommended] | ||
|
||
```bash | ||
python -m venv cytrics_venv | ||
source cytrics_venv/bin/activate | ||
``` | ||
|
||
2. Install Surfactant with pip | ||
|
||
```bash | ||
pip install surfactant | ||
``` | ||
|
||
### For Developers: | ||
|
||
1. Create a virtual environment with python >= 3.8 [Optional, but recommended] | ||
|
||
```bash | ||
python -m venv cytrics_venv | ||
source cytrics_venv/bin/activate | ||
``` | ||
|
||
2. Clone sbom-surfactant | ||
|
||
```bash | ||
git clone [email protected]:LLNL/Surfactant.git | ||
``` | ||
|
||
3. Create an editable surfactant install (changes to code will take effect immediately): | ||
|
||
```bash | ||
pip install -e . | ||
``` | ||
|
||
To install optional dependencies required for running pytest and pre-commit: | ||
|
||
```bash | ||
pip install -e ".[test,dev]" | ||
``` | ||
|
||
## Understanding the SBOM Output | ||
|
||
### Software | ||
|
||
TODO: Section information | ||
This section contains a list of entries relating to each piece of software found in the sample. Metadata including file size, vendor, version, etc are included in this section along with a uuid to uniquely identify the software entry. | ||
|
||
### Relationships | ||
|
||
TODO: Section information | ||
This section contains information on how each of the software entries in the previous section are linked. | ||
|
||
**Uses**: this relationship type means that x software uses y software i.e. y is a helper module to x\ | ||
**Contains**: this relationship type means that x software contains y software (often x software is an installer or archive such as a zip file) | ||
### Observations | ||
|
||
TODO: Section information |
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 |
---|---|---|
@@ -1,17 +1,51 @@ | ||
# Plugins | ||
|
||
TODO: About the plugin system | ||
The surfactant plugin system uses the [pluggy](https://pluggy.readthedocs.io/en/stable) module. This module is used by projects such as pytest and tox for their plugin systems; installing and writing plugins for surfactant is a similar to using plugins for those projects. Most of the core surfactant functionality is also implemented as plugins (see [surfactant/output](https://github.com/LLNL/Surfactant/tree/main/surfactant/output), [surfactant/infoextractors](https://github.com/LLNL/Surfactant/tree/main/surfactant/infoextractors), [surfactant/filetypeid](https://github.com/LLNL/Surfactant/tree/main/surfactant/filetypeid), and [surfactant/relationships](https://github.com/LLNL/Surfactant/tree/main/surfactant/relationships)). | ||
|
||
## Creating a Plugin | ||
|
||
### Step 1: Write Plugin | ||
|
||
TODO: Function implementation instructions | ||
In order to create a plugin, you will need to write your implementation for one or more of the functions in the [hookspec.py](https://github.com/LLNL/Surfactant/tree/main/surfactant/plugin/hookspecs.py) file. Which functions you implement will depend on the goals of your plugin. | ||
|
||
#### Brief overview of functions | ||
[identify_file_type](https://github.com/LLNL/Surfactant/tree/main/surfactant/plugin/hookspecs.py#L15) | ||
- Return a string representation of the type of file passed in | ||
|
||
[extract_file_info](https://github.com/LLNL/Surfactant/tree/main/surfactant/plugin/hookspecs.py#L29) | ||
- Determine how file info is supposed to be extracted | ||
|
||
[establish_relationships](https://github.com/LLNL/Surfactant/tree/main/surfactant/plugin/hookspecs.py#L47) | ||
- Determines how to establish relationships between the software/metadata that has been passed to it | ||
|
||
[write_sbom](https://github.com/LLNL/Surfactant/tree/main/surfactant/plugin/hookspecs.py#L70) | ||
- Determine what format to write the SBOM to file | ||
|
||
[read_sbom](https://github.com/LLNL/Surfactant/tree/main/surfactant/plugin/hookspecs.py#L80) | ||
- If reading from input SBOMs, specifies what format the input SBOMs are | ||
|
||
### Step 2. Write .toml File | ||
|
||
TODO: Plugin metadata details | ||
Once you have written your plugin, you will need to write a pyproject.toml file. Include any relevant project metadata/dependencies for your plugin, as well as an entry-point specification (example below) to make the plugin discoverable by surfactant. Once you write your .toml file, you can `pip install .` your plugin. | ||
More information on entry points can be found [here](https://setuptools.pypa.io/en/latest/userguide/entry_point.html#entry-points-syntax) | ||
|
||
#### Example | ||
|
||
TODO: Example .toml files | ||
#### sampleplugin.py | ||
```python | ||
import surfactant.plugin | ||
from surfactant.sbomtypes import SBOM | ||
|
||
@surfactant.plugin.hookimpl | ||
def write_sbom(sbom: SBOM, outfile) -> None: | ||
outfile.write(sbom.to_json(indent=10)) | ||
``` | ||
#### pyproject.toml | ||
```toml | ||
... generic pyproject info ... | ||
[project.entry-points."surfactant"] | ||
sampleplugin = "sampleplugin" | ||
``` | ||
From the same folder as your sampleplugin files, run `pip install .` to install your plugin and surfactant will automatically load and use the plugin. | ||
|
||
Another example can be found in the [surfactantplugin-checksec.py](https://github.com/LLNL/Surfactant/tree/main/surfactantplugin-checksec.py) folder. There you can see the [pyproject.toml](https://github.com/LLNL/Surfactant/tree/main/surfactantplugin-checksec.py/pyproject.toml) file with the `[project.entry-points."surfactant"]` entry. In the [surfactantplugin_checksec.py](https://github.com/LLNL/Surfactant/tree/main/surfactantplugin-checksec.py/surfactantplugin_checksec.py) file, you can identify the hooked functions with the `@surfactant.plugin.hookimpl` hook. |
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