Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
This python library parses symbolic file permission modes as used by GNU chmod, part of the coreutils package. For example:
>>> from symbolicmode import *
>>> oct(symbolic_to_numeric_permissions('a=rx,u+w'))
'0o755'
It also has a "chmod" function:
>>> chmod('a=rx,u+w', '/tmp/foo')
>>> chmod('755', '/tmp/foo')
>>> chmod(0o755, '/tmp/foo')
For convenience it can take permissions in the form of an integer, a numeric string or the symbolic permissions.
This library is fully compatible with GNU Coreutils "chmod" command. It fully implements all mode specifiers except for the purely numeric versions ("755") that chmod does, as verified by manual, unit, and extensive fuzz testing.
My fuzz testing was against version 8.32-4.1ubuntu1). Fuzz testing tools are in the "fuzzchmod" directory.
Convert a symbolic file permission string to its numeric equivalent.
The function takes a symbolic permission description string in the format of
user[=,+,-]permissions,group[=,+,-]permissions,other[=,+,-]permissions
.
The available permission characters are r
(read), w
(write), x
(execute),
X
(execute if a directory), s
(setuid/setgid), and t
(sticky bit), or a single
character from: 'u', 'g', 'o'.
Args:
symbolic_perm
(str): The symbolic permission description string.initial_mode
(int, optional): The mode to start off with. If changing mode of an
existing file, this is it's current mode, and can also impact 'X'.is_directory
(bool, optional): A boolean indicating whether the file is a directory.
This affects the behavior of the X
permission. Defaults to False.umask
(int, optional): Umask to use for "=[modes]" operation. If not specified, the
system umask will be used.Returns:
Raises:
Examples:
>>> symbolic_to_numeric_permissions("u=rwx,g=rx,o=r")
0o754
>>> symbolic_to_numeric_permissions("u=rwX", is_directory=True)
0o700
>>> symbolic_to_numeric_permissions("u=rws,g=rx,o=r")
0o4754
>>> symbolic_to_numeric_permissions("=rw", initial_mode=0o4777, is_directory=False, umask=0o027)
0o640
Change the mode (permissions) of a specified file or directory.
The mode can be specified as an integer, a string representing an octal integer or as a string representing symbolic permissions (e.g., 'u=rwx,g=r,o=r').
Parameters:
Returns: None
Raises:
Examples:
# Change the mode of a file using an octal integer:
chmod(0o755, '/path/to/file')
# Change the mode of a file using a digit string:
chmod('755', '/path/to/file')
# Change the mode of a directory using symbolic permissions
chmod('u=rwx,g=rx,o=r', '/path/to/directory')
Permission instructions are 1 or more comma separated values of the form: "[ugoa...][[=+-][PERMS...]...]".
USERS can be:
Operators are:
PERMS can be a combination of the following (except for u/g/o which if specified must be the only, single, PERM provided:
Notes on instructions:
In the "fuzzchmod" directory is a set of programs for fuzz testing SymbolicMode against the system "chmod" to try to ensure correctness for even unusual inputs.
CC0 1.0 Universal, see LICENSE file for more information.
FAQs
Code to handle symbolic permissions like GNU chmod does ('a=rx,u+w')
We found that symbolicmode demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.