Skip to content

Commit

Permalink
feat(python): vulnerable pillow version
Browse files Browse the repository at this point in the history
  • Loading branch information
elsapet committed May 30, 2024
1 parent 0cd5011 commit 83b1f36
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 0 deletions.
30 changes: 30 additions & 0 deletions rules/python/third_parties/pillow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
patterns:
- import pillow
- from pillow import $<_>
dependency_check: true
dependency:
name: pillow
min_version: 6.2.1
filename: requirements.txt
languages:
- python
severity: medium
metadata:
description: Usage of vulnerable Pillow library
remediation_message: |
## Description
A vulnerability was identified in Pillow versions less than 6.2.2, meaning that the library may allocate excessive memory, or have unusually long time processing times, when processing certain (specially crafted, malformed) image files.
## Remediations
- **Do** ensure that your application uses version 6.2.2 or greater of Pillow.
## References
- [Pillow documentation](https://pillow.readthedocs.io/en/stable/)
- [NIST detail for vulnerability](https://nvd.nist.gov/vuln/detail/CVE-2019-16865)
cwe_id:
- 770
id: python_third_parties_pillow
documentation_url: https://docs.bearer.com/reference/rules/python_third_parties_pillow
36 changes: 36 additions & 0 deletions tests/python/third_parties/pillow/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const {
createNewInvoker,
getEnvironment,
} = require("../../../helper.js")
const { ruleId, ruleFile, testBase } = getEnvironment(__dirname)

describe(ruleId, () => {
const invoke = createNewInvoker(ruleId, ruleFile, testBase)

test("insecure", () => {
const testCase = "insecure"

const results = invoke(testCase)

expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})

test("secure", () => {
const testCase = "secure_dependency"

const results = invoke(testCase)

expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})

test("secure_dependency", () => {
const testCase = "secure_no_dependency"

const results = invoke(testCase)

expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# bearer:expected python_third_parties_pillow
import pillow
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pillow=6.2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pillow=6.2.2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import pillow
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pillow=6.2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# not importing the dodgy library
import world from hello

0 comments on commit 83b1f36

Please sign in to comment.