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

Safety Authentication in the shell #525

Closed
akshitadixit opened this issue May 2, 2024 · 6 comments
Closed

Safety Authentication in the shell #525

akshitadixit opened this issue May 2, 2024 · 6 comments

Comments

@akshitadixit
Copy link

  • safety version: 3.2.0
  • Python version: 3.9.6
  • Operating System: macOS

Description

I want to be able to use safety in my CI/CD pipeline but if safety auth is going to return a clickable browser authentication url, it will not be feasible. Is there any way to authenticate in the shell itself?

MichaIng added a commit to motioneye-project/motioneye that referenced this issue May 14, 2024
Safety "check" has been superseded by "scan": https://docs.safetycli.com/safety-docs/safety-cli-3/migrating-from-safety-cli-2.x-to-safety-cli-3.x#switching-to-the-new-scan-command
But it requires to create an account and authenticate. Until we decide whether we want to create a motionEye account for this, and when we know how to authenticate non-interactively, we stick with "check": pyupio/safety#525

Ignore disputed CVE-2018-20225. pip (intentioanlly) pulls the latest version of a module from PyPI, if an older version is available in "extra" indexes added via "extra-index-url" config/arg. If the module does not exist on PyPI at all, an attacker could upload one with the same name, injecting an unintended module into the user's project. This is of course naturally true when installing one module with multiple indexes, same as when installing an APT package with multiple APT repositories present. "extra"-index-url is not meant to override, but extend the indexes. To enforce a different index, and mitigate this potential risk for modules not uploaded to PyPI, use "index-url" arg/config instead.

Remove obsolete workaround.

Signed-off-by: MichaIng <[email protected]>
@MichaIng
Copy link

The SAFETY_API_KEY environment variable seems to work, or using the --key= CLI option: https://docs.safetycli.com/safety-docs/support/invalid-api-key-error#using-the-safety-api-key-in-safety-cli

MichaIng added a commit to motioneye-project/motioneye that referenced this issue May 28, 2024
Print motion path and version in debug log when detecting and when starting motion.

Print error code when motion failed to start.

Align variable names and avoid unused variables.

Safety "check" has been superseded by "scan": https://docs.safetycli.com/safety-docs/safety-cli-3/migrating-from-safety-cli-2.x-to-safety-cli-3.x#switching-to-the-new-scan-command
But it requires to create an account and authenticate. Until we decide whether we want to create a motionEye account for this, and when we know how to authenticate non-interactively, we stick with "check": pyupio/safety#525

Ignore disputed CVE-2018-20225. pip (intentioanlly) pulls the latest version of a module from PyPI, if an older version is available in "extra" indexes added via "extra-index-url" config/arg. If the module does not exist on PyPI at all, an attacker could upload one with the same name, injecting an unintended module into the user's project. This is of course naturally true when installing one module with multiple indexes, same as when installing an APT package with multiple APT repositories present. "extra"-index-url is not meant to override, but extend the indexes. To enforce a different index, and mitigate this potential risk for modules not uploaded to PyPI, use "index-url" arg/config instead.

Remove obsolete workaround.

Fix error log when ffmpeg executable could NOT print version.

Add executable path to debug log.

Quote motion executable path, which is not assured to work in shell without quotation.

Align variable and structuring code comments.

Signed-off-by: MichaIng <[email protected]>
@yacine-harbi
Copy link

--key works with safety check not safety scan if I'm not mistaken.

@MichaIng
Copy link

MichaIng commented Jun 1, 2024

Here is an example in the docs where it is used with safety scan: https://docs.safetycli.com/safety-docs/output/detecting-vulnerabilities-and-sharing-results-via-email#command

Also the variable must work, sine it is used in the official GitHub Action with safety scan: https://github.com/pyupio/safety-action/blob/main/entrypoint.sh

--stage cicd likely makes sense as well, but I could not find a hint about exact effect of this. Probably it ignores the test environment and concentrates on the project (source code) and declared dependencies only, while otherwise it checks the current environment as well, interpreting it as the one the project is finally running in. Just an idea which somehow would make sense to me.

@yacine-harbi
Copy link

Thanks it's working now (I used --key=API_KEY not --key API_KEY). I had to add --stage cicd or I would get "Invalid value: 'api_key' auth type isn't allowed with the 'Stage.development' stage."

@MichaIng
Copy link

MichaIng commented Jun 1, 2024

Okay, whatever this "development" stage shall be: Who is doing manual dependency vulnerability checks while coding? Documentation about all of this is missing, or not prominent enough, e.g. searching for stage in the docs does not lead to any other results than examples for --stage cicd usage.

So it is currently not possible to run safety scan without --stage cicd from a non-GUI console?

@akshitadixit
Copy link
Author

Thank you so much for the help, forgot to reply promptly, but it worked 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants