Skip to content

Commit 8940a6f

Browse files
committed
Pip: Add a sanity check for a setup.py's license field length
The field is specified to be a "short string" which is "a single line of text, not more than 200 characters" [1]. Respect that limit, which also filters out cases where people add full license texts to the field. [1] https://docs.python.org/3/distutils/setupscript.html#additional-meta-data Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent ee75aac commit 8940a6f

File tree

1 file changed

+5
-1
lines changed
  • analyzer/src/main/kotlin/managers

1 file changed

+5
-1
lines changed

analyzer/src/main/kotlin/managers/Pip.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ class Pip(
170170
}
171171

172172
companion object {
173+
private const val SHORT_STRING_MAX_CHARS = 200
174+
173175
private val INSTALL_OPTIONS = arrayOf(
174176
"--no-warn-conflicts",
175177
"--prefer-binary"
@@ -437,7 +439,9 @@ class Pip(
437439
}
438440

439441
private fun getLicenseFromLicenseField(value: String?): String? {
440-
if (value.isNullOrBlank() || value == "UNKNOWN" || "\n" in value) return null
442+
if (value.isNullOrBlank() || value == "UNKNOWN" || value.length > SHORT_STRING_MAX_CHARS || "\n" in value) {
443+
return null
444+
}
441445

442446
// Apply a work-around for projects that declare licenses in classifier-syntax in the license field.
443447
return getLicenseFromClassifier(value) ?: value

0 commit comments

Comments
 (0)