Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/automated inventories #119

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.emporous.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
emporous build collection leaf-workspace --plain-http localhost:5000/exercises/leaf:latest --dsconfig leaf-dataset-config.yaml
emporous 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.emporous.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
emporous build collection root-workspace --plain-http localhost:5000/exercises/root:latest --dsconfig root-dataset-config.yaml
emporous push --plain-http localhost:5000/exercises/root:latest
```
9. Create inventory
```bash
emporous 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