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

Kubescape fix not working #1392

Open
corvusmod opened this issue Sep 18, 2023 · 3 comments
Open

Kubescape fix not working #1392

corvusmod opened this issue Sep 18, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@corvusmod
Copy link

corvusmod commented Sep 18, 2023

Description

fix command is not working

Environment

OS: MacOS
Version: 2.9.1

Steps To Reproduce

Following the steps when running kubescape fix -h

  1. kubescape scan . --format json --output output.json
  2. kubescape fix output.json

Expected behavior

Yamls modified with the fixed detected

Actual Behavior

Error getting json file

`1)

  • Control configurations are empty
    ✅ Scan results saved. filename: output.json

Overall compliance-score (100- Excellent, 0- All failed): 76

➜ ls -la output.json
-rw-r--r--@ 1 luis.cuervo staff 225865 Sep 18 14:37 output.json

➜ kubescape fix output.json
ℹ️ Reading report file...
Error: stat : no such file or directory
Usage:
kubescape fix [flags]

`

Additional context

Tried in several projects and always the same result.

@corvusmod corvusmod added the bug Something isn't working label Sep 18, 2023
@dwertent
Copy link
Contributor

@corvusmod I am trying to reproduce this with no success.
I see the error call you encounter is stat.
I'm not sure why this is happening.

Can you try to run the fix command with the full path?

kubescape fix /full/path/output.json

@corvusmod
Copy link
Author

corvusmod commented Sep 19, 2023

I think I identified the problem, but it doesn't seem related to fix argument. These are my test:

  • My default project is configured with an internal gitlab server, if I run scan there I get:

kubescape scan . --format json --output output.json

✅ Initialized scanner
❗ in setContextMetadata. case: git-url; error: repository host 'lab.technest.es' not supported
✅ Loaded policies
✅ Loaded exceptions
✅ Loaded account configurations
❗ Git scan skipped. error: failed to get commit information for file: manifests-dev/cams-km-helm-chart/charts/cams-base-chart/templates/env-secret.yaml
✅ Done accessing local objects
Control: C-0090 100% |██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| (48/48, 169 it/s)
✅ Done scanning GitLocal
✅ Done aggregating results

And if I run fix against this json

kubescape fix /Users/redacted/sources/kk/output.json

ℹ️ Reading report file...
Error: stat : no such file or directory

BUT...

I deleted .git folder and then. git init, git add all files and git commit...

kubescape scan . --format json --output output.json

✅ Initialized scanner
✅ Loaded policies
✅ Loaded exceptions
✅ Loaded account configurations
✅ Done accessing local objects
Control: C-0037 100% |██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| (48/48, 173 it/s)
✅ Done scanning Directory
✅ Done aggregating results

And fix... WORK!!!!

kubescape fix /Users/redacted/sources/kk/output.json
ℹ️ Reading report file...
ℹ️ The following changes will be applied:

So there is something related to git configuration when it can't connect with an internal gitlab server.

I hope that you can identify the problem.

Also, there is any way to disable git scan when you only want to test local files even then this folder has git configuration?

Thanks

@dwertent
Copy link
Contributor

Interesting!
Thank you for reporting this, we will look into it.

Also, there is any way to disable git scan when you only want to test local files even then this folder has git configuration?

I will first need to understand the root cause because the fact that you are scanning a git repo should not affect the results.

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

2 participants