Skip to content

cnspec scan --incognito throws errors if logged in #1667

@philipbalinov

Description

@philipbalinov

Describe the bug
After login with cnspec login, immediately running cnspec scan --incognito will fail the scan with a list of failed to compile filters for query errors

Running the scan without logging in (e.g. cnspec scan --incognito --config /dev/null), or without --incognito works fine

To Reproduce
Steps to reproduce the behavior:

  1. Run a simple docker container
    docker run -it ubuntu bash
  2. Install cnspec
    apt update && apt install -y curl && bash -xc "$(curl -L https://install.mondoo.com/sh)"
  3. Log into a space
    cnspec login --token XXXXXXXXXXXXXXX
  4. Run an incognito scan and see it fail
    cnspec scan --incognito
  5. Run the same scan without incognito and see it pass
    cnspec scan

Expected behavior
A successful scan

Screenshots or CLI Output

root@9570c1fb857f:/# cnspec scan local --incognito 
DBG using provider os with connector local
DBG Started a new runtime (1 total)
DBG no need to update provider last-refresh=14m28.574850722s provider=os
DBG Log level set to debug
DBG Started a new runtime (2 total)
→ loaded configuration from /root/.config/mondoo/mondoo.yml using source default
→ using service account credentials
DBG initialize client authentication issuer=mondoo/ams kid=//agents.api.mondoo.app/spaces/hungry-almeida-565576/serviceaccounts/2xUQzXBMNE5qvjMDH0GB7mHapHJ
→ discover related assets for 1 asset(s)
DBG Started a new runtime (3 total)
DBG local> run command uname -s
DBG local> run command uname -m
DBG local> run command uname -m
DBG platform> detected os family=["debian","linux","unix","os"] platform=ubuntu
DBG unable to read /sys/class/dmi/id/product_name error="open /sys/class/dmi/id/product_name: no such file or directory"
DBG unable to read /sys/devices/virtual/dmi/id/product_name error="open /sys/devices/virtual/dmi/id/product_name: no such file or directory"
DBG unable to read /sys/class/dmi/id/sys_vendor error="open /sys/class/dmi/id/sys_vendor: no such file or directory"
DBG unable to read /sys/class/dmi/id/sys_vendor error="open /sys/class/dmi/id/sys_vendor: no such file or directory"
DBG unable to read /sys/class/dmi/id/product_version error="open /sys/class/dmi/id/product_version: no such file or directory"
DBG unable to read /sys/class/dmi/id/bios_vendor error="open /sys/class/dmi/id/bios_vendor: no such file or directory"
DBG local> run command hostname -f
DBG detected platform ids id-detector=["cloud-detect","hostname"] platform-ids=["//platformid.api.mondoo.app/hostname/9570c1fb857f"]
DBG detected asset asset=9570c1fb857f
DBG start scan name=9570c1fb857f platform={"arch":"aarch64","family":["debian","linux","unix","os"],"kind":"baremetal","labels":{"distro-id":"ubuntu"},"metadata":{"distro-id":"ubuntu"},"name":"ubuntu","technology_url_segments":["os","linux","ubuntu","24.04"],"title":"Ubuntu 24.04.1 LTS","version":"24.04"}
DBG connecting to asset 9570c1fb857f (Ubuntu 24.04.1 LTS)
DBG run scan asset=9570c1fb857f
DBG failed to find where function for assessment, this can happen with empty assessments
DBG failed to find where function for assessment, this can happen with empty assessments
DBG could not complete scan for asset asset=9570c1fb857f
DBG add scan error to report asset=9570c1fb857f
Asset: (Ubuntu 24.04.1 LTS) 9570c1fb857f
----------------------------------------

error: failed to compile filters for query //policy.api.mondoo.app/queries/asset-overview-azure-creator
failed to compile filters for query //policy.api.mondoo.app/queries/asset-overview-azure-owner
failed to compile filters for query //policy.api.mondoo.app/queries/mondoo-asset-inventory-azure-storageAccounts-containers-single
failed to compile filters for query //policy.api.mondoo.app/queries/mondoo-asset-inventory-azure-virtualmachines-managedDisk-single
....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions