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

fix: Warn instead of panic when API resource not found or forbidden #73

Merged
merged 10 commits into from
Jul 26, 2023

Commits on Jul 24, 2023

  1. fix: Don't emit both Info & Error logs for PolicyReports

    Before this fix, we were doing log.Info().Err(err), which emits a
    one-line log that is both info and error:
    
    {"level":"info","error":"resource not found","namespace":"demo2","time":"2023-07-24T15:23:17+02:00","message":"no pre-existing PolicyReport, will create one at the end of the scan"}
    
    Signed-off-by: Víctor Cuadrado Juan <[email protected]>
    viccuad committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    ccb9695 View commit details
    Browse the repository at this point in the history
  2. fix: Skip clusterwide resources in getResourcesForPolicies

    We are looking for namespaced resources, clusterwide resources get
    checked in getClusterWideResourcesForPolicies()
    
    Signed-off-by: Víctor Cuadrado Juan <[email protected]>
    viccuad committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    478f74f View commit details
    Browse the repository at this point in the history
  3. fix: Warn instead of panic when API resource not found or forbidden

    When policies are configured with a spec.rules GVK,
    if resource doesn't exist because it has an incorrect GVK,
    or if because it is a CRD that we don't know about,
    emit warning and skip resource from scan.
    
    The same for when policies are configured with a spec.rules GVK that the
    audit-scanner lacks permissions for,
    emit warning and skip resource from scan.
    
    Signed-off-by: Víctor Cuadrado Juan <[email protected]>
    viccuad committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    6682cbd View commit details
    Browse the repository at this point in the history
  4. docs: locally run with a specific ServiceAccount

    Signed-off-by: Víctor Cuadrado Juan <[email protected]>
    viccuad committed Jul 24, 2023
    Configuration menu
    Copy the full SHA
    4de1faf View commit details
    Browse the repository at this point in the history

Commits on Jul 25, 2023

  1. chore: Reword info message

    Signed-off-by: Víctor Cuadrado Juan <[email protected]>
    viccuad committed Jul 25, 2023
    Configuration menu
    Copy the full SHA
    3ee1086 View commit details
    Browse the repository at this point in the history
  2. tests: Add fakeClient now that we check if res are namespaced

    Needed, as we need a client when we do `fetcher.isNamespacedResource()`.
    
    Signed-off-by: Víctor Cuadrado Juan <[email protected]>
    viccuad committed Jul 25, 2023
    Configuration menu
    Copy the full SHA
    c41a12a View commit details
    Browse the repository at this point in the history
  3. tests: Add test for incorrect GVKs

    Signed-off-by: Víctor Cuadrado Juan <[email protected]>
    viccuad committed Jul 25, 2023
    Configuration menu
    Copy the full SHA
    925e018 View commit details
    Browse the repository at this point in the history
  4. tests: Add test to show clusterwide res are skipped

    Signed-off-by: Víctor Cuadrado Juan <[email protected]>
    viccuad committed Jul 25, 2023
    Configuration menu
    Copy the full SHA
    ff99749 View commit details
    Browse the repository at this point in the history
  5. tests: Add TestLackOfPermsWhenGettingResources()

    Add a test that checks that we don't error nor panic when trying to
    filter resources that are forbidden (because the client lacks
    permissions, normally because the ServiceAccount is insufficient).
    
    Signed-off-by: Víctor Cuadrado Juan <[email protected]>
    viccuad committed Jul 25, 2023
    Configuration menu
    Copy the full SHA
    04c72ca View commit details
    Browse the repository at this point in the history
  6. chore: Make golint-ci happy, and me a bit less

    Signed-off-by: Víctor Cuadrado Juan <[email protected]>
    viccuad committed Jul 25, 2023
    Configuration menu
    Copy the full SHA
    91944ce View commit details
    Browse the repository at this point in the history