-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da0db0d
commit 29ad9b6
Showing
21 changed files
with
762 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"log" | ||
|
||
v1beta1 "github.com/aquasecurity/tracee/types/api/v1beta1" | ||
) | ||
|
||
type CloudContext struct { | ||
Provider string | ||
} | ||
|
||
type Context_Cloud struct { | ||
Cloud *CloudContext | ||
v1beta1.IContextContext `json:"-"` | ||
} | ||
|
||
func main() { | ||
e := v1beta1.Event{ | ||
Id: 123, | ||
Name: "ptrace", | ||
} | ||
|
||
e.SetProcessContext(&v1beta1.ProcessContext{ | ||
Binary: "/bin/bash", | ||
Pid: 10, | ||
NamespacePid: 1, | ||
UserId: 1, | ||
UserName: "root", | ||
}) | ||
// process := e.GetProcessContext() | ||
|
||
e.SetContainerContext(&v1beta1.ContainerContext{ | ||
Id: "lala", | ||
Name: "xx", | ||
Started: true, | ||
}) | ||
// container := e.GetContainerContext() | ||
|
||
e.SetKubernetesContext(&v1beta1.KubernetesContext{ | ||
Name: "pod-name", | ||
Namespace: "prod", | ||
Uid: "uid", | ||
Sandbox: "sandbox", | ||
}) | ||
// kubernetes := e.GetKubernetesContext() | ||
|
||
// fmt.Printf("process: %+v\n", process) | ||
// fmt.Printf("container: %+v\n", container) | ||
// fmt.Printf("kubernetes: %+v\n", kubernetes) | ||
|
||
cloud := CloudContext{Provider: "gcloud"} | ||
// fmt.Printf("cloud: %+v\n\n", cloud) | ||
// fmt.Printf("before len: %d\n", len(e.Context)) | ||
e.Context = append(e.Context, &v1beta1.Context{Context: &Context_Cloud{Cloud: &cloud}}) | ||
// fmt.Printf("after len: %d\n", len(e.Context)) | ||
|
||
// fmt.Printf("event: %+v\n", e) | ||
|
||
b, err := json.Marshal(e) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
fmt.Println(string(b)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package flags | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/aquasecurity/tracee/pkg/errfmt" | ||
"github.com/aquasecurity/tracee/pkg/server/grpc" | ||
) | ||
|
||
func PrepareGRPCServer(listenAddr string) (*grpc.Server, error) { | ||
if len(listenAddr) == 0 { | ||
return nil, nil | ||
} | ||
|
||
addr := strings.SplitN(listenAddr, ":", 2) | ||
|
||
if addr[0] != "tcp" && addr[0] != "unix" { | ||
return nil, errfmt.Errorf("grpc supported protocols are tcp or unix. eg: tcp:4466, unix:/tmp/tracee.sock") | ||
} | ||
|
||
if len(addr[1]) == 0 { | ||
return nil, errfmt.Errorf("grpc addr cannot be empty") | ||
} | ||
|
||
return grpc.New(addr[0], addr[1]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.