kubearmor / kubearmor-client

KubeArmor cli tool aka kArmor :robot:
Apache License 2.0
34 stars 82 forks source link

chore(logs): add output format option to `karmor logs` command #447

Closed navin772 closed 1 month ago

navin772 commented 2 months ago

Fixes: #439

Introduced new flags for pretty and normal printing:

karmor logs --output json karmor logs --output pretty-json karmor logs --output text

Shorthand -> -o

The --json flag is still present: karmor logs --json

Output:

$ ./karmor logs -o pretty-json

local port to be used for port forwarding kubearmor-relay-8464877449-sp5mt: 32816 
Created a gRPC client (localhost:32816)
Checked the liveness of the gRPC server
Started to watch alerts

{
  "Timestamp": 1719459063,
  "UpdatedTime": "2024-06-27T03:31:03.302163Z",
  "ClusterName": "default",
  "HostName": "navin",
  "HostPPID": 8384,
  "HostPID": 14768,
  "PPID": 8384,
  "PID": 14768,
  "UID": 1000,
  "ParentProcessName": "/usr/bin/bash",
  "ProcessName": "/usr/bin/date",
  "PolicyName": "hsp-kubearmor-dev-proc-path-block-fromsource",
  "Severity": "5",
  "Type": "MatchedHostPolicy",
  "Source": "/usr/bin/bash",
  "Operation": "Process",
  "Resource": "/usr/bin/date",
  "Data": "lsm=SECURITY_BPRM_CHECK",
  "Enforcer": "BPFLSM",
  "Action": "Block",
  "Result": "Permission denied",
  "Cwd": "/"
}
daemon1024 commented 2 months ago

Can we squash the commits please? Thanks

DelusionalOptimist commented 1 month ago

@navin772 please rebase with upstream main once to fix the failing tests.

navin772 commented 1 month ago

@DelusionalOptimist all the tests are now passing.

daemon1024 commented 1 month ago

Please squash the commits 🙌 Rest LGTM

navin772 commented 1 month ago

@daemon1024 can you rebase and merge the PR, having some issues with squashing.