Skip to content

Commit

Permalink
Tidy up of README and output of generate command
Browse files Browse the repository at this point in the history
  • Loading branch information
crashdump committed Aug 17, 2023
1 parent 7383459 commit 25fbd41
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 12 deletions.
64 changes: 60 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,32 @@
[![GoDoc](https://godoc.org/github.com/crashdump/venlock?status.svg)](https://godoc.org/github.com/crashdump/venlock)


## Install
## Install/Run

You can download precompiled binaries, containers or install directly from source.

### Binaries (arm, amd64)

Precompiled binaries can be [found here](https://github.com/crashdump/venlock/releases).

### Docker (arm, amd64)

```bash
docker run -ti docker pull ghcr.io/crashdump/venlock:latest
```

### Source

```bash
go install github.com/crashdump/venlock/cmd/venlock@latest
```

## Use

### Subcommands

```bash
venlock ./sources/
./venlock
```

┌─────────────┐
Expand All @@ -39,9 +55,10 @@ venlock ./sources/
--help (default: false)


```bash
venlock enumerate test/fixtures
### Enumerate

```bash
./venlock enumerate test/fixtures
```

┌─────────────┐
Expand Down Expand Up @@ -79,6 +96,45 @@ venlock enumerate test/fixtures
compression


### Enforce

```bash
./venlock enforce -c test/fixtures/config.json test/fixtures
```

enforce -c test/fixtures/config.json test/fixtures
┌─────────────┐
│ Vendor Lock │
└─────────────┘

Searching for foreign libraries in source code...

> Go...
... found foreign libraries:
- github.com/PuerkitoBio/goquery
- github.com/yuin/goldmark
- golang.org/x/oauth2
- github.com/andybalholm/cascadia
- github.com/golang/protobuf
- golang.org/x/net
- golang.org/x/sys
- golang.org/x/text
- google.golang.org/appengine
- google.golang.org/protobuf

> Maven...

No mismatch.

> Npm...

No mismatch.

non-compliant: found unexpected libraries


## Contribute

### Build

```bash
Expand Down
39 changes: 31 additions & 8 deletions cmd/venlock/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ func main() {
Email: "ap@cdfr.net",
}},
Commands: []*cli.Command{
/*
* Enumerate
*/
{
Name: "enumerate",
Aliases: []string{"e"},
Expand Down Expand Up @@ -70,6 +73,9 @@ func main() {
return nil
},
},
/*
* Generate
*/
{
Name: "generate",
Aliases: []string{"g"},
Expand Down Expand Up @@ -100,6 +106,9 @@ func main() {
return nil
},
},
/*
* Enforce
*/
{
Name: "enforce",
Aliases: []string{"v"},
Expand Down Expand Up @@ -131,35 +140,49 @@ func main() {

logger.print("Searching for foreign libraries in source code...")

var found []string
compliant := true

showMismatch := func(libs []string, compliant *bool) {
if len(libs) == 0 {
logger.printResult("")
logger.printResult("No mismatch.")
return
}
*compliant = false
logger.printResult("... found foreign libraries:")
for _, lib := range libs {
logger.printfResult(" - %s", lib)
}
}

logger.printHeader("Go...")
f, err := enforce[gomod.GoMod[gomod.Library], gomod.Library](config, path)
if err != nil {
logger.printFatal(err.Error())
}
found = append(found, f...)
showMismatch(f, &compliant)

logger.printHeader("Maven...")
f, err = enforce[maven.Maven[maven.Library], maven.Library](config, path)
if err != nil {
logger.printFatal(err.Error())
}
found = append(found, f...)
showMismatch(f, &compliant)

logger.printHeader("Npm...")
f, err = enforce[npm.Npm[npm.Library], npm.Library](config, path)
if err != nil {
logger.printFatal(err.Error())
}
found = append(found, f...)
showMismatch(f, &compliant)

if len(found) == 0 {
logger.print("")
logger.print("No mismatch, success!")
if compliant {
logger.printHeader("success.")
return nil
}
return errors.New("found unexpected libraries")

logger.print("")
return errors.New("non-compliant: found unexpected libraries")
},
},
},
Expand Down

0 comments on commit 25fbd41

Please sign in to comment.