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.
PyTestArch is an open source library that allows users to define architectural rules and test their code against them. It is generally inspired by ArchUnit.
PyTestArch is available via PyPI and can be installed e.g. via pip: pip install pytestarch
. To also install the
optional dependency matplotlib, which is required to draw the created dependency graphs, install pytestarch[visualization]
Three steps are required to test an architectural rule:
from pytestarch import get_evaluable_architecture
evaluable = get_evaluable_architecture("/home/dummy/project", "/home/dummy/project/src")
This will scan all python files under /home/dummy/project/src for imports and build an internal representation that can later be queried. The first parameter /home/dummy/project helps PyTestArch to differentiate between internal and external dependencies. This evaluable can be used for multiple architectural rule checks; if you are using pytest, you could use a fixture for this evaluable object.
from pytestarch import Rule
rule = (
Rule()
.modules_that()
.are_named("project.src.moduleB")
.should_not()
.be_imported_by_modules_that()
.are_sub_modules_of("project.src.moduleA")
)
This rule represents the architectural requirements that a module named "project.src.moduleB" should not be imported by any module that is a submodule of "project.src.moduleA", excluding "project.src.moduleA" itself.
rule.assert_applies(evaluable)
That's it!
FAQs
Test framework for software architecture based on imports between modules
We found that pytestarch 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.