Skip to content

Commit

Permalink
feat: adds syft integration for automated component metadata collection
Browse files Browse the repository at this point in the history
Closes #113

Signed-off-by: Jennifer Power <[email protected]>
  • Loading branch information
jpower432 committed Jan 18, 2023
1 parent 1f708a8 commit 8fef7da
Show file tree
Hide file tree
Showing 11 changed files with 1,521 additions and 0 deletions.
98 changes: 98 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,104 @@ Notice how only the _root.txt_ file was retrieved as only this file contained th

# Experimental

## Create a software inventory from a collection and the links
### How to Test

#### Steps
1. Create a linked collection. Start by creating a leaf collection by creating a workspace directory called `leaf-workspace`.

```bash
mkdir leaf-workspace
```

2. Create a simple file called `leaf.txt` containing a single word within the workspace:

```bash
echo "leaf" > leaf-workspace/leaf.txt
```

3. Create the Dataset Configuration within a file called `leaf-dataset-config.yaml` with the following content:

```bash
cat << EOF > leaf-dataset-config.yaml
kind: DataSetConfiguration
apiVersion: client.uor-framework.io/v1alpha1
collection:
components:
cpes:
- "cpe:2.3:a:leaf-test:leaf-test:107.0.5304"
language: "go"
name: "leaf-package"
version: "v0.0.1"
files:
- file: "*.txt"
attributes:
animal: "fish"
habitat: "ocean"
size: "small"
color: "blue"
type: "leaf"
EOF
```

4. Build and push the leaf collection to the remote registry

```bash
uor-client-go build collection leaf-workspace --plain-http localhost:5000/exercises/leaf:latest --dsconfig leaf-dataset-config.yaml
uor-client-go push --plain-http localhost:5000/exercises/leaf:latest
```

5. Build a Root collection and link the previously built collection

Create a new directory for the root collection called `root-workspace`

```bash
mkdir root-workspace
```

6. Create a simple file called `root.txt` containing a single word within the workspace:

```bash
echo "root" > root-workspace/root.txt
```
7. Create the Dataset Configuration within a file called `root-dataset-config.yaml` with the following content:

```bash
cat << EOF > root-dataset-config.yaml
kind: DataSetConfiguration
apiVersion: client.uor-framework.io/v1alpha1
collection:
linkedCollections:
- localhost:5000/exercises/leaf:latest
components:
cpes:
- "cpe:2.3:a:root-test:root-test:107.0.5304"
language: "go"
name: "root-package"
version: "v0.0.1"
files:
- file: "*.txt"
attributes:
animal: "cat"
habitat: "house"
size: "small"
color: "orange"
type: "root"
EOF
```
8. Build and push the root collection to the remote registry

```bash
uor-client-go build collection root-workspace --plain-http localhost:5000/exercises/root:latest --dsconfig root-dataset-config.yaml
uor-client-go push --plain-http localhost:5000/exercises/root:latest
```
9. Create inventory
```bash
uor-client-go create inventory localhost:5000/exercises/root:latest --plain-http
```

> TIP: To avoid the requirement to manually input component information, test with a file that is already in a packaged format. This has been successfully tested with rpms.

## Publish content to use with a container runtime
#### Steps
1. Create a simple Go application
Expand Down
37 changes: 37 additions & 0 deletions cmd/client/commands/create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package commands

import (
"github.com/spf13/cobra"

"github.com/emporous/emporous-go/cmd/client/commands/options"
)

// CreateOptions describe configuration options that can
// be set using the create subcommand.
type CreateOptions struct {
*options.Common
options.Remote
options.RemoteAuth
}

// NewCreateCmd creates a new cobra.Command for the create subcommand.
func NewCreateCmd(common *options.Common) *cobra.Command {
o := CreateOptions{Common: common}

cmd := &cobra.Command{
Use: "create",
Short: "Create artifacts from existing OCI artifacts",
SilenceErrors: false,
SilenceUsage: false,
RunE: func(cmd *cobra.Command, _ []string) error {
return cmd.Help()
},
}

o.Remote.BindFlags(cmd.PersistentFlags())
o.RemoteAuth.BindFlags(cmd.PersistentFlags())

cmd.AddCommand(NewInventoryCmd(&o))

return cmd
}
Loading

0 comments on commit 8fef7da

Please sign in to comment.