Skip to content
This repository has been archived by the owner on May 21, 2023. It is now read-only.

Commit

Permalink
Detect more capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
cugu committed Jan 12, 2022
1 parent 8f497c2 commit 4d86af7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ go install github.com/cugu/[email protected]
`gocap generate <path>` prints a valid `go.cap` file. It lists all dependency packages that require critical permissions
like file access, execution rights or network access.

**! `gocap generate` runs on package basis and the path argument must point to a Go package (there must be .go files) not a Go Module. Also `gocap generate` needs the dependenies downloaded before, e.g. run `go mod download`**.
**! `gocap generate` runs on package basis and the path argument must point to a Go package (there must be .go files)
not a Go Module. Also `gocap generate` needs the dependenies downloaded before, e.g. run `go mod download`**.

*Example*

Expand Down Expand Up @@ -112,3 +113,14 @@ github.com/alecthomas/kong
github.com/pkg/errors
unnecessary capability 'network', please remove from go.cap file
```

## Capabilities

| Name | Description | Packages |
|---------|-------------------------------------------------------------------------------------------------------------------------------------|--------------------|
| file | Read and write access to files | os io/ioutil |
| network | Read and write to the network | net net/http |
| execute | Execute other binaries | os/exec reflect |
| runtime | Access system information | runtime |
| syscall | Perform any system call in context of the software. Unsafe might indicate a //go:linkname and login of external C or assembler code | syscall, C, unsafe |

2 changes: 2 additions & 0 deletions capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ var permissionMap = map[string][]string{
"os/exec": {"execute"},
"syscall": {"syscall"},
"runtime": {"runtime"},
"reflect": {"execute"},
"unsafe": {"syscall"},
}

func toCapabilities(dependencies []string) []string {
Expand Down

0 comments on commit 4d86af7

Please sign in to comment.