Skip to content

Avoid using eval to parse id_charset #54

Open
@jvkersch

Description

@jvkersch

The register objects code uses the builtin eval function twice to assemble a set of valid characters for object IDs, for example:

id_charset = eval(id_charset)

The idea is that the user can specify the list of admissible ID characters using a Python expression in the configuration file:

id_charset: 'string.ascii_letters + string.digits + ".-_~"'

This is unsafe since it allows executing arbitrary code (try specifying id_charset: 'import os; os.system("rm -rf /")' in the config file), and also somewhat unnecessary in my opinion. I would recommend just specifying the list of admissible characters directly:

id_charset: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_~'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions