Skip to content

Sanitize dynamic version value #183

Open
@sanmai-NL

Description

@sanmai-NL

Is your feature request related to a problem? Please describe.

https://pdm-backend.fming.dev/metadata/#writing-dynamic-version-to-file suggests a procedure for writing a package version to a file. Python source code generation is also described. Generating source code with unsanitized input is dangerous (CWE-20).

Describe the solution you'd like

As a security conscious developer, I want PDM to sanitize the version string that is replaced in the template, so that when something unexpected happens (e.g., env var is tainted in a CI pipeline), a code injection vulnerability is mitigated.

Besides the existing {} (‘raw string’) placeholder which puts the raw version characters in the file, add, e.g., a placeholder{str_version} that directly inserts a quoted (non-f-)string.

Warn when the raw string placeholder is used, both in the docs and at runtime.

Alternatively, deprecate the feature to write the version file according a template.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions