Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No results in sarif file #1434

Closed
musabmirza-amperon opened this issue Oct 16, 2023 · 13 comments
Closed

No results in sarif file #1434

musabmirza-amperon opened this issue Oct 16, 2023 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@musabmirza-amperon
Copy link

Description

sarif file does not have the findings in it.

Environment

OS: MacOS Venture 13
Version: Your current version is: v2.9.1

Steps To Reproduce

  1. Create a deployment.yaml file (taken from here) :
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
  1. Run kubescape scan deployment.yaml --verbose -f sarif. This would output something like this:

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

################################################################################
Source: deployment.yaml
ApiVersion: apps/v1
Kind: Deployment
Name: nginx-deployment

Controls: 29 (Failed: 12, action required: 2)

┌──────────┬────────────────────────────────┬────────────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────┐
│ �[1;93mSEVERITY�[0m │ �[1;93m         CONTROL NAME         �[0m │ �[1;93m               DOCS               �[0m │ �[1;93m                              ASSISTED REMEDIATION                              �[0m │
├──────────┼────────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│ High     │ Resource limits                │ https://hub.armosec.io/docs/c-0009 │ spec.template.spec.containers[0].resources.limits.cpu=YOUR_VALUE                 │
│          │                                │                                    │ spec.template.spec.containers[0].resources.limits.memory=YOUR_VALUE              │
├          ┼────────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│          │ Resources CPU limit and        │ https://hub.armosec.io/docs/c-0050 │ spec.template.spec.containers[0].resources.limits.cpu=YOUR_VALUE                 │
│          │ request                        │                                    │ spec.template.spec.containers[0].resources.requests.cpu=YOUR_VALUE               │
├          ┼────────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│          │ Resources memory limit and     │ https://hub.armosec.io/docs/c-0004 │ spec.template.spec.containers[0].resources.limits.memory=YOUR_VALUE              │
│          │ request                        │                                    │ spec.template.spec.containers[0].resources.requests.memory=YOUR_VALUE            │
├──────────┼────────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│ Low      │ Configured readiness probe     │ https://hub.armosec.io/docs/c-0018 │ spec.template.spec.containers[0].readinessProbe=YOUR_VALUE                       │
├          ┼────────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│          │ Immutable container filesystem │ https://hub.armosec.io/docs/c-0017 │ spec.template.spec.containers[0].securityContext.readOnlyRootFilesystem=true     │
├          ┼────────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│          │ K8s common labels usage        │ https://hub.armosec.io/docs/c-0077 │ metadata.labels=YOUR_VALUE                                                       │
│          │                                │                                    │ spec.template.metadata.labels=YOUR_VALUE                                         │
├          ┼────────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│          │ Pods in default namespace      │ https://hub.armosec.io/docs/c-0061 │ metadata.namespace=YOUR_NAMESPACE                                                │
├──────────┼────────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│ Medium   │ Allow privilege escalation     │ https://hub.armosec.io/docs/c-0016 │ spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation=false  │
├          ┼────────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│          │ Configured liveness probe      │ https://hub.armosec.io/docs/c-0056 │ spec.template.spec.containers[0].livenessProbe=YOUR_VALUE                        │
├          ┼────────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│          │ Ingress and Egress blocked     │ https://hub.armosec.io/docs/c-0030 │                                                                                  │
├          ┼────────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│          │ Linux hardening                │ https://hub.armosec.io/docs/c-0055 │ spec.template.spec.containers[0].securityContext.seccompProfile=YOUR_VALUE       │
│          │                                │                                    │ spec.template.spec.containers[0].securityContext.seLinuxOptions=YOUR_VALUE       │
│          │                                │                                    │ spec.template.spec.containers[0].securityContext.capabilities.drop[0]=YOUR_VALUE │
├          ┼────────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────┤
│          │ Non-root containers            │ https://hub.armosec.io/docs/c-0013 │ spec.template.spec.containers[0].securityContext.runAsNonRoot=true               │
│          │                                │                                    │ spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation=false  │
└──────────┴────────────────────────────────┴────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────┘


Controls: 48 (Failed: 12, Passed: 34, Action Required: 2)
Failed Resources by Severity: Critical — 0, High — 3, Medium — 5, Low — 4

┌──────────┬───────────────────────────────────────────────────────┬──────────────────┬───────────────┬────────────────────┐
│ �[1;93mSEVERITY�[0m │ �[1;93m                    CONTROL NAME                     �[0m │ �[1;93mFAILED RESOURCES�[0m │ �[1;93mALL RESOURCES�[0m │ �[1;93m% COMPLIANCE-SCORE�[0m │
├──────────┼───────────────────────────────────────────────────────┼──────────────────┼───────────────┼────────────────────┤
│ Critical │ CVE-2022-39328-grafana-auth-bypass                    │        0         │       0       │        100%        │
│ High     │ Forbidden Container Registries                        │        0         │       1       │ Action Required *  │
│ High     │ Resources memory limit and request                    │        1         │       1       │         0%         │
│ High     │ Resource limits                                       │        1         │       1       │         0%         │
│ High     │ Applications credentials in configuration files       │        0         │       1       │        100%        │
│ High     │ List Kubernetes secrets                               │        0         │       0       │        100%        │
│ High     │ Host PID/IPC privileges                               │        0         │       1       │        100%        │
│ High     │ HostNetwork access                                    │        0         │       1       │        100%        │
│ High     │ Writable hostPath mount                               │        0         │       1       │        100%        │
│ High     │ Insecure capabilities                                 │        0         │       1       │        100%        │
│ High     │ HostPath mount                                        │        0         │       1       │        100%        │
│ High     │ Resources CPU limit and request                       │        1         │       1       │         0%         │
│ High     │ Privileged container                                  │        0         │       1       │        100%        │
│ High     │ CVE-2021-25742-nginx-ingress-snippet-annotation-vu... │        0         │       0       │        100%        │
│ High     │ CVE-2022-47633-kyverno-signature-bypass               │        0         │       0       │        100%        │
│ Medium   │ Exec into container                                   │        0         │       0       │        100%        │
│ Medium   │ Data Destruction                                      │        0         │       0       │        100%        │
│ Medium   │ Non-root containers                                   │        1         │       1       │         0%         │
│ Medium   │ Allow privilege escalation                            │        1         │       1       │         0%         │
│ Medium   │ Mount service principal                               │        0         │       1       │        100%        │
│ Medium   │ Ingress and Egress blocked                            │        1         │       1       │         0%         │
│ Medium   │ Delete Kubernetes events                              │        0         │       0       │        100%        │
│ Medium   │ Automatic mapping of service account                  │        0         │       1       │        100%        │
│ Medium   │ Cluster-admin binding                                 │        0         │       0       │        100%        │
│ Medium   │ CoreDNS poisoning                                     │        0         │       0       │        100%        │
│ Medium   │ Container hostPort                                    │        0         │       1       │        100%        │
│ Medium   │ Access container service account                      │        0         │       0       │        100%        │
│ Medium   │ Cluster internal networking                           │        0         │       0       │        100%        │
│ Medium   │ Linux hardening                                       │        1         │       1       │         0%         │
│ Medium   │ Configured liveness probe                             │        1         │       1       │         0%         │
│ Medium   │ Sudo in container entrypoint                          │        0         │       1       │        100%        │
│ Medium   │ Portforwarding privileges                             │        0         │       0       │        100%        │
│ Medium   │ No impersonation                                      │        0         │       0       │        100%        │
│ Medium   │ Container runtime socket mounted                      │        0         │       1       │        100%        │
│ Medium   │ Images from allowed registry                          │        0         │       1       │ Action Required *  │
│ Medium   │ CVE-2022-24348-argocddirtraversal                     │        0         │       0       │        100%        │
│ Medium   │ Anonymous access enabled                              │        0         │       0       │        100%        │
│ Low      │ Access Kubernetes dashboard                           │        0         │       1       │        100%        │
│ Low      │ Immutable container filesystem                        │        1         │       1       │         0%         │
│ Low      │ Configured readiness probe                            │        1         │       1       │         0%         │
│ Low      │ SSH server running inside container                   │        0         │       0       │        100%        │
│ Low      │ Network mapping                                       │        0         │       0       │        100%        │
│ Low      │ Pods in default namespace                             │        1         │       1       │         0%         │
│ Low      │ PSP enabled                                           │        0         │       0       │        100%        │
│ Low      │ Naked PODs                                            │        0         │       0       │        100%        │
│ Low      │ Image pull policy on latest tag                       │        0         │       1       │        100%        │
│ Low      │ Label usage for resources                             │        0         │       1       │        100%        │
│ Low      │ K8s common labels usage                               │        1         │       1       │         0%         │
├──────────┼───────────────────────────────────────────────────────┼──────────────────┼───────────────┼────────────────────┤
│          │                   RESOURCE SUMMARY                    │        1         │       1       │       70.83%       │
└──────────┴───────────────────────────────────────────────────────┴──────────────────┴───────────────┴────────────────────┘
FRAMEWORKS: AllControls (compliance: 70.21), NSA (compliance: 66.67), MITRE (compliance: 100.00)

* Control configurations are empty
  1. Note that there are several vulnerabilities highlighted there
  2. Run cat report.sarif which results in this:
{
  "version": "2.1.0",
  "$schema": "https://json.schemastore.org/sarif-2.1.0-rtm.5.json",
  "runs": [
    {
      "tool": {
        "driver": {
          "informationUri": "https://armosec.io",
          "name": "kubescape",
          "rules": []
        }
      },
      "results": []
    }
  ]
}

Expected behavior

All the vulns reported in stdout would also be present in the report.sarif file.

Actual Behavior

report.sarif has an empty results[] array.

Additional context

I tested it out with other production manifests (e.g. kustomize for argocd etc) and the results contained only couple of vulns (that too with a warning or note) but nothing more.

@musabmirza-amperon musabmirza-amperon added the bug Something isn't working label Oct 16, 2023
@dwertent
Copy link
Contributor

Thank you @musabmirza-amperon for reporting. It looks like the issue occurs when scanning a specific file.
We will fix this issue, but as a workaround, you can scan the directory instead of the file and it should work.

@musabmirza-amperon
Copy link
Author

I am new to kubescape so apologies for anything silly I might be be pointing out.

That workaround is okay, however there is a larger issue which I tried to simplify in this report. The issue is that the sarif report seems incomplete and missing several reports showed in stdout.

Here is how to reproduce it by scanning argocd. I will use kustomize to render the templates into a dir (as you mentioned) and then scan the dir. Notice how the report on stdout and sarif differ (sarif missing stuff):

mkdir argocd-rendered

kustomize build https://github.com/argoproj/argo-cd//manifests/cluster-install > argocd-rendered/out.yamlkubescape 

kubescape scan argocd-rendered -f sarif
# Result:
  Initialized scanner
✅  Loaded policies
✅  Loaded exceptions
✅  Loaded account configurations
✅  Done accessing local objects
Control: C-0046 100% |███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| (48/48, 142 it/s)
✅  Done scanning Directory
✅  Done aggregating results

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Controls: 48 (Failed: 17, Passed: 29, Action Required: 2)
Failed Resources by Severity: Critical — 0, High — 23, Medium — 22, Low — 18

┌──────────┬────────────────────────────────────┬──────────────────┬───────────────┬────────────────────┐
│ SEVERITY │            CONTROL NAME            │ FAILED RESOURCES │ ALL RESOURCES │ % COMPLIANCE-SCORE │
├──────────┼────────────────────────────────────┼──────────────────┼───────────────┼────────────────────┤
│ High     │ Forbidden Container Registries     │        0         │       7       │ Action Required *  │
│ High     │ Resources memory limit and request │        7         │       7       │         0%         │
│ High     │ Resource limits                    │        7         │       7       │         0%         │
│ High     │ List Kubernetes secrets            │        2         │       7       │        71%         │
│ High     │ Resources CPU limit and request    │        7         │       7       │         0%         │
│ Medium   │ Exec into container                │        1         │       7       │        86%         │
│ Medium   │ Data Destruction                   │        2         │       7       │        71%         │
│ Medium   │ Ingress and Egress blocked         │        6         │      14       │        57%         │
│ Medium   │ Delete Kubernetes events           │        2         │       7       │        71%         │
│ Medium   │ Cluster-admin binding              │        1         │       7       │        86%         │
│ Medium   │ CoreDNS poisoning                  │        2         │       7       │        71%         │
│ Medium   │ Access container service account   │        2         │       2       │         0%         │
│ Medium   │ Configured liveness probe          │        4         │       7       │        43%         │
│ Medium   │ Portforwarding privileges          │        1         │       7       │        86%         │
│ Medium   │ No impersonation                   │        1         │       7       │        86%         │
│ Medium   │ Images from allowed registry       │        0         │       7       │ Action Required *  │
│ Low      │ Configured readiness probe         │        4         │       7       │        43%         │
│ Low      │ Pods in default namespace          │        7         │       7       │         0%         │
│ Low      │ Label usage for resources          │        7         │       7       │         0%         │
├──────────┼────────────────────────────────────┼──────────────────┼───────────────┼────────────────────┤
│          │          RESOURCE SUMMARY          │        9         │      42       │       76.49%       │
└──────────┴────────────────────────────────────┴──────────────────┴───────────────┴────────────────────┘
FRAMEWORKS: AllControls (compliance: 76.60), NSA (compliance: 90.48), MITRE (compliance: 85.71)

* Control configurations are empty
✅  Scan results saved. filename: report.sarif

View results
────────────
Now, take your scan results to the next level with actionable insights on ARMO Platform.

Sign up for free here - https://cloud.armosec.io/repository-scanning/323b93f9-c300-4ffc-b079-8583a152c396

ℹ️   Run with '--verbose'/'-v' flag for detailed resources view

Now if you check the sarif file, its not reporting any HIGH or MEDIUM severities, there are just warnings and notes. For instance, C-0015 which is reported in stdout (List kubernetes secrets) is missing in the sarif file and many others too.

What am I missing?

@havardj900
Copy link

havardj900 commented Oct 18, 2023 via email

@rcohencyberarmor
Copy link
Contributor

Hi @musabmirza-amperon,
I hope that in the correction will be enter in the next kubescape release.
I'll just will enter several examples and expected results:

  1. kubescape scan deployment.yaml --verbose -f sarif - for this command we will see only the SARIF output(without the pretty print before it as above)
  2. kubescape scan deployment.yaml --verbose -f sarif -o report - for this command we will see the pretty printer as above and the SARIF output will be in the report.sarif file

@musabmasood
Copy link

Hi @rcohencyberarmor

Have you tried to reproduce #1434 (comment) please?

The issue is that kubescape is not including many severities in the sarif file which are reported in stdout. I hope you're not leaving this feature out intentionally? :)

@rcohencyberarmor
Copy link
Contributor

yes @musabmasood. in the next version of kubescape all the severities in the sarif file will be the same as reported in stdout

@musabmirza-amperon
Copy link
Author

Can you link the issue/ticket for the above the above statement ^ 🙏?

@rcohencyberarmor
Copy link
Contributor

Hi @musabmasood,
The issue of missing specific controls in the SARIF is not solved yet.
The main issue there is related to RBAC.
Some controls that related to RBAC will not appear in the SARIF report, since we create a new ID for RBAC related controls which not represent the file that contain the k8s config object.
We will solve this issue, but not in the next few days, It is in our road map.
Thx for reporting this issue!

@musabmirza-amperon
Copy link
Author

What I don't understand is that the html and json outputs contain everything, but not the sarif report 🤔

@musabmirza-amperon
Copy link
Author

I updated to verion 3.0.0 and I can confirm that the SEVERITY levels are still not present in the saved sarif file. Everything appears as warning. Is this intentional?

cc @musabmasood

@artur-borys
Copy link

I'm on 3.0.1 and the sarif file still has empty results

@dwertent
Copy link
Contributor

dwertent commented Mar 1, 2024

Resolved in release v3.0.4

@dwertent dwertent closed this as completed Mar 1, 2024
@mbgit2
Copy link

mbgit2 commented Mar 8, 2024

This issue is marked as resolved but running

 kubescape scan deployment.yaml --verbose -f sarif

still results in

{
  "version": "2.1.0",
  "$schema": "https://json.schemastore.org/sarif-2.1.0.json",
  "runs": [
    {
      "tool": {
        "driver": {
          "informationUri": "https://armosec.io",
          "name": "kubescape",
          "rules": []
        }
      },
      "results": []
    }
  ]
}

Am I missing something, I did make sure to run v3.0.4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants