Skip to content

Account for pathlib chmod setting insecure permissions #1042

@costaparas

Description

@costaparas

The current implementation of B103: set_bad_file_permissions works well for uses of the chmod functions from the os module directly.

It fails to report insecure permissions when the equivalent functions from the pathlib module are being used instead.

As a simple example, consider:

import pathlib

p = pathlib.Path("dummy_file")
p.chmod(0o666)

This should trigger an equivalent warning just as os.chmod("dummy_file", 0o666) currently does.

The code should be generalized to support the pathlib version of the chmod functions as well.

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