tonybaloney / pycharm-security

Finds security holes in your Python projects from PyCharm and GitHub
https://pycharm-security.readthedocs.io/en/latest/?badge=latest
MIT License
327 stars 21 forks source link

Exception in plugin when opening PyCharm #327

Open marjeta42 opened 2 years ago

marjeta42 commented 2 years ago

Describe the bug Exception in plugin when opening PyCharm. I have been using this plugin for a while, so I guess the problem is probably related to new project I just cloned from GitHub: learn-terraform-lambda-api-gateway

To Reproduce

  1. I opened PyCharm
  2. This opened newly cloned project https://github.com/hashicorp/learn-terraform-lambda-api-gateway.git
  3. See error

Screenshots image

Additional context

Stacktrace

java.lang.IllegalArgumentException: Don't use '/usr/bin/python2.7' on macOS (see IDEA-271050). Args: [/JetBrains/Toolbox/apps/PyCharm-P/ch-0/213.6777.50/PyCharm.app/Contents/plugins/python/helpers/packaging_tool.py, list] at com.intellij.execution.configurations.GeneralCommandLine.validateAndPrepareCommandLine(GeneralCommandLine.java:422) at com.intellij.execution.configurations.GeneralCommandLine.createProcess(GeneralCommandLine.java:352) at com.jetbrains.python.packaging.PyPackageManagerImpl.getPythonProcessOutput(PyPackageManagerImpl.java:279) at com.jetbrains.python.packaging.PyPackageManagerImpl.getPythonProcessResult(PyPackageManagerImpl.java:233) at com.jetbrains.python.packaging.PyPackageManagerImpl.getPythonProcessResult(PyPackageManagerImpl.java:226) at com.jetbrains.python.packaging.PyPackageManagerImpl.getHelperResult(PyPackageManagerImpl.java:220) at com.jetbrains.python.packaging.PyPackageManagerImpl.getHelperResult(PyPackageManagerImpl.java:209) at com.jetbrains.python.packaging.PyPackageManagerImpl.collectPackages(PyPackageManagerImpl.java:159) at com.jetbrains.python.packaging.PyPackageManagerImplBase.refreshAndGetPackages(PyPackageManagerImplBase.java:209) at security.packaging.PyPackageSecurityScan.checkPackagesInSdks(PyPackageSecurityScan.kt:47) at security.packaging.PyPackageSecurityScan.checkPackages(PyPackageSecurityScan.kt:30) at security.packaging.PythonPackageVulnerabilityStartupTask$runActivity$1.run(PythonPackageVulnerabilityStartupTask.kt:16) at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:436) at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:120) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsync$5(CoreProgressManager.java:496) at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:244) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:188) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:624) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:698) at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:646) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:623) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:175) at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:244) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665) at java.base/java.lang.Thread.run(Thread.java:829)

marjeta42 commented 2 years ago

Actually, it seems the problem is with PyCharm.

Although it created a virtual environment, it didn't associate it with the project, so the plugin was trying to use the MacOS default, which (even though this Mac was purchased in 2021) is still 2.7...

marjeta42 commented 2 years ago

Though it would be nice if plugin displayed a nice warning and ignored the project.