From d504a6fe6c3e48e9d98cef135848de8bec446142 Mon Sep 17 00:00:00 2001 From: Georgiana-Elena Maxim Date: Wed, 31 Jul 2024 10:43:13 +0300 Subject: [PATCH] fix: support for pipenv with python 3.12 --- package-lock.json | 14 +++--- package.json | 2 +- .../workspaces/pipenv-app-python-3.12/Pipfile | 12 +++++ .../basic-test-all-languages.spec.ts | 47 +++++++++++++++++++ 4 files changed, 67 insertions(+), 8 deletions(-) create mode 100644 test/acceptance/workspaces/pipenv-app-python-3.12/Pipfile diff --git a/package-lock.json b/package-lock.json index 8639acba31..b2e0547ce1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -78,7 +78,7 @@ "snyk-nuget-plugin": "2.7.2", "snyk-php-plugin": "1.9.2", "snyk-policy": "^1.25.0", - "snyk-python-plugin": "2.1.1", + "snyk-python-plugin": "2.2.0", "snyk-resolve-deps": "4.7.3", "snyk-sbt-plugin": "2.18.1", "snyk-swiftpm-plugin": "1.4.1", @@ -21286,9 +21286,9 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "node_modules/snyk-python-plugin": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/snyk-python-plugin/-/snyk-python-plugin-2.1.1.tgz", - "integrity": "sha512-TK2EecV9MQ9uKCybyR/7KotCHVVNmtc8QWp6w1O8NP8zPW9OZS1eXKoDf6ot0lnth4J+9Cec/2IgCUjJocC4uQ==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/snyk-python-plugin/-/snyk-python-plugin-2.2.0.tgz", + "integrity": "sha512-VSX1Pl04THkxDkWg3d1SpiELe4Erw87s3Qd6gEXGyuZRgAAHeLoSV47/PJNnx5KAl3CU88b3LxJZZgKfMNCwPw==", "dependencies": { "@snyk/cli-interface": "^2.11.2", "@snyk/dep-graph": "^1.28.1", @@ -40552,9 +40552,9 @@ } }, "snyk-python-plugin": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/snyk-python-plugin/-/snyk-python-plugin-2.1.1.tgz", - "integrity": "sha512-TK2EecV9MQ9uKCybyR/7KotCHVVNmtc8QWp6w1O8NP8zPW9OZS1eXKoDf6ot0lnth4J+9Cec/2IgCUjJocC4uQ==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/snyk-python-plugin/-/snyk-python-plugin-2.2.0.tgz", + "integrity": "sha512-VSX1Pl04THkxDkWg3d1SpiELe4Erw87s3Qd6gEXGyuZRgAAHeLoSV47/PJNnx5KAl3CU88b3LxJZZgKfMNCwPw==", "requires": { "@snyk/cli-interface": "^2.11.2", "@snyk/dep-graph": "^1.28.1", diff --git a/package.json b/package.json index 5442b9bf9e..a67a014e8b 100644 --- a/package.json +++ b/package.json @@ -126,7 +126,7 @@ "snyk-nuget-plugin": "2.7.2", "snyk-php-plugin": "1.9.2", "snyk-policy": "^1.25.0", - "snyk-python-plugin": "2.1.1", + "snyk-python-plugin": "2.2.0", "snyk-resolve-deps": "4.7.3", "snyk-sbt-plugin": "2.18.1", "snyk-swiftpm-plugin": "1.4.1", diff --git a/test/acceptance/workspaces/pipenv-app-python-3.12/Pipfile b/test/acceptance/workspaces/pipenv-app-python-3.12/Pipfile new file mode 100644 index 0000000000..771014d69b --- /dev/null +++ b/test/acceptance/workspaces/pipenv-app-python-3.12/Pipfile @@ -0,0 +1,12 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +"Jinja2" = "*" + +[dev-packages] + +[requires] +python_version = "3.12" \ No newline at end of file diff --git a/test/jest/acceptance/snyk-test/basic-test-all-languages.spec.ts b/test/jest/acceptance/snyk-test/basic-test-all-languages.spec.ts index 270e063306..c48bac5d2f 100644 --- a/test/jest/acceptance/snyk-test/basic-test-all-languages.spec.ts +++ b/test/jest/acceptance/snyk-test/basic-test-all-languages.spec.ts @@ -139,6 +139,53 @@ describe('`snyk test` of basic projects for each language/ecosystem', () => { expect(result.stderr).toMatch(wrongPythonCommand); }); + test('run `snyk test` on a pipenv project', async () => { + const project = await createProjectFromWorkspace('pipenv-app'); + let pythonCommand = 'python'; + + await runCommand(pythonCommand, ['--version']).catch(function() { + pythonCommand = 'python3'; + }); + + console.debug('Using: ' + pythonCommand); + let pipenvResult = await runCommand('pipenv', ['install'], { + shell: true, + cwd: project.path(), + }); + + expect(pipenvResult.code).toEqual(0); + + const { code } = await runSnykCLI('test -d --command=' + pythonCommand, { + cwd: project.path(), + env, + }); + + expect(code).toEqual(0); + }); + + test('run `snyk test` on a pipenv python 3.12 project', async () => { + const project = await createProjectFromWorkspace('pipenv-app-python-3.12'); + let pythonCommand = 'python'; + + await runCommand(pythonCommand, ['--version']).catch(function() { + pythonCommand = 'python3'; + }); + + console.debug('Using: ' + pythonCommand); + let pipenvResult = await runCommand('pipenv', ['install'], { + shell: true, + cwd: project.path(), + }); + + expect(pipenvResult.code).toEqual(0); + + const { code } = await runSnykCLI('test -d --command=' + pythonCommand, { + cwd: project.path(), + env, + }); + expect(code).toEqual(0); + }); + test('run `snyk test` on a gradle project', async () => { const project = await createProjectFromWorkspace('gradle-app');