mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4af46fcf9 | ||
|
|
e9d3b573b3 |
50
README.md
50
README.md
@@ -89,6 +89,8 @@ Want to contribute? Want to discuss something? Have an issue?
|
||||
* [Configure and run customized frameworks](https://youtu.be/12Sanq_rEhs)
|
||||
* Customize controls configurations. [Kubescape CLI](https://youtu.be/955psg6TVu4), [Kubescape SaaS](https://youtu.be/lIMVSVhH33o)
|
||||
|
||||
<details><summary>Windows</summary>
|
||||
|
||||
## Install on Windows
|
||||
|
||||
**Requires powershell v5.0+**
|
||||
@@ -102,6 +104,9 @@ Note: if you get an error you might need to change the execution policy (i.e. en
|
||||
``` powershell
|
||||
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
|
||||
```
|
||||
</details>
|
||||
|
||||
<details><summary>MacOS</summary>
|
||||
|
||||
## Install on macOS
|
||||
|
||||
@@ -111,6 +116,9 @@ Set-ExecutionPolicy RemoteSigned -scope CurrentUser
|
||||
2. ```sh
|
||||
brew install kubescape
|
||||
```
|
||||
</details>
|
||||
|
||||
<details><summary>Nix/NixOS</summary>
|
||||
|
||||
## Install on NixOS or with nix (Community)
|
||||
|
||||
@@ -144,6 +152,7 @@ home-manager:
|
||||
|
||||
Or to your profile (not preferred): `nix-env --install -A nixpkgs.kubescape`
|
||||
|
||||
</details>
|
||||
|
||||
## Usage & Examples
|
||||
|
||||
@@ -270,35 +279,10 @@ kubescape scan framework nsa --use-from /path/nsa.json
|
||||
```
|
||||
|
||||
|
||||
## Scan Periodically using Helm - Contributed by [@yonahd](https://github.com/yonahd)
|
||||
## Scan Periodically using Helm
|
||||
[Please follow the instructions here](https://hub.armosec.io/docs/installation-of-armo-in-cluster)
|
||||
[helm chart repo](https://github.com/armosec/armo-helm)
|
||||
|
||||
## Scan using docker image
|
||||
|
||||
Official Docker image `quay.io/armosec/kubescape`
|
||||
|
||||
```
|
||||
docker run -v "$(pwd)/example.yaml:/app/example.yaml quay.io/armosec/kubescape scan /app/example.yaml
|
||||
```
|
||||
|
||||
If you wish, you can [build the docker image on your own](build/README.md)
|
||||
|
||||
# Submit data manually
|
||||
|
||||
Use the `submit` command if you wish to submit data manually
|
||||
|
||||
## Submit scan results manually
|
||||
|
||||
> Support forward compatibility by using the `--format-version v2` flag
|
||||
|
||||
First, scan your cluster using the `json` format flag: `kubescape scan framework <name> --format json --format-version v2 --output path/to/results.json`.
|
||||
|
||||
Now you can submit the results to the Kubescape SaaS version -
|
||||
```
|
||||
kubescape submit results path/to/results.json
|
||||
```
|
||||
|
||||
# Integrations
|
||||
|
||||
## VS Code Extension
|
||||
@@ -314,6 +298,8 @@ View Kubescape scan results directly in [Lens IDE](https://k8slens.dev/) using k
|
||||
|
||||
# Building Kubescape
|
||||
|
||||
<details><summary>Windows</summary>
|
||||
|
||||
## Windows
|
||||
|
||||
```
|
||||
@@ -323,9 +309,13 @@ OR
|
||||
```
|
||||
make build
|
||||
```
|
||||
</details>
|
||||
|
||||
<details><summary>Linux / MacOS</summary>
|
||||
|
||||
## Linux / MacOS
|
||||
|
||||
|
||||
1. Install libgit2 dependency
|
||||
|
||||
```
|
||||
@@ -345,11 +335,15 @@ make build
|
||||
make test
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## VS code configuration samples
|
||||
|
||||
You can use the samples files below to setup your VS code environment for building and debugging purposes.
|
||||
|
||||
|
||||
<details><summary>.vscode/settings.json</summary>
|
||||
|
||||
```json5
|
||||
// .vscode/settings.json
|
||||
{
|
||||
@@ -360,6 +354,9 @@ You can use the samples files below to setup your VS code environment for buildi
|
||||
}
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
<details><summary>.vscode/launch.json</summary>
|
||||
|
||||
```json5
|
||||
// .vscode/launch.json
|
||||
@@ -382,6 +379,7 @@ You can use the samples files below to setup your VS code environment for buildi
|
||||
]
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
# Under the hood
|
||||
|
||||
|
||||
20
httphandler/Makefile
Normal file
20
httphandler/Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
.PHONY: test all build libgit2
|
||||
|
||||
# default task invoked while running make
|
||||
all: libgit2 build
|
||||
|
||||
export CGO_ENABLED=1
|
||||
|
||||
# build and install libgit2
|
||||
libgit2:
|
||||
git submodule update --init --recursive
|
||||
cd git2go; make install-static
|
||||
|
||||
# go build tags
|
||||
TAGS = "static"
|
||||
|
||||
build:
|
||||
go build -v -tags=$(TAGS) .
|
||||
|
||||
test:
|
||||
go test -v -tags=$(TAGS) ./...
|
||||
@@ -1,6 +1,6 @@
|
||||
# Kubescape HTTP Handler Package
|
||||
|
||||
Running `kubescape` will start up a webserver on port `8080` which will serve the following API's:
|
||||
Running `kubescape` will start up a web-server on port `8080` which will serve the following API's:
|
||||
|
||||
### Trigger scan
|
||||
|
||||
@@ -153,6 +153,12 @@ curl --header "Content-Type: application/json" \
|
||||
http://127.0.0.1:8080/v1/scan
|
||||
```
|
||||
|
||||
#### Read process heap
|
||||
```bash
|
||||
curl --request POST http://127.0.0.1:8080/heap -o heap
|
||||
go tool pprof heap
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
* [Prometheus](examples/prometheus/README.md)
|
||||
|
||||
@@ -3,6 +3,7 @@ package v1
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"runtime/pprof"
|
||||
|
||||
utilsapisv1 "github.com/armosec/opa-utils/httpserver/apis/v1"
|
||||
utilsmetav1 "github.com/armosec/opa-utils/httpserver/meta/v1"
|
||||
@@ -219,6 +220,13 @@ func (handler *HTTPHandler) Ready(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
// return process heap information
|
||||
func (handler *HTTPHandler) Heap(w http.ResponseWriter, r *http.Request) {
|
||||
defer recover()
|
||||
w.WriteHeader(http.StatusOK)
|
||||
pprof.WriteHeapProfile(w)
|
||||
}
|
||||
|
||||
func (handler *HTTPHandler) recover(w http.ResponseWriter, scanID string) {
|
||||
response := utilsmetav1.Response{}
|
||||
if err := recover(); err != nil {
|
||||
|
||||
@@ -21,6 +21,7 @@ const (
|
||||
prometheusMmeticsPath = "/v1/metrics"
|
||||
livePath = "/livez"
|
||||
readyPath = "/readyz"
|
||||
heap = "/heap"
|
||||
)
|
||||
|
||||
// SetupHTTPListener set up listening http servers
|
||||
@@ -50,6 +51,7 @@ func SetupHTTPListener() error {
|
||||
rtr.HandleFunc(resultsPath, httpHandler.Results)
|
||||
rtr.HandleFunc(livePath, httpHandler.Live)
|
||||
rtr.HandleFunc(readyPath, httpHandler.Ready)
|
||||
rtr.HandleFunc(heap, httpHandler.Heap)
|
||||
|
||||
server.Handler = rtr
|
||||
|
||||
|
||||
Reference in New Issue
Block a user