Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
.. |v| image:: https://img.shields.io/pypi/v/formic2.svg :target: https://pypi.python.org/pypi/formic2 :alt: Last stable version (PyPI)
.. [doc] image:: https://readthedocs.org/projects/formic/badge/?version=latest :target: https://formic.readthedocs.io/ :alt: ReadTheDocs
Formic is forked from https://bitbucket.org/aviser/formic. The original project only supports python2.7 and has not been maintained for a long time.
I added Python3 supports and fixed some issues.
Formic now can work on any Python 2.6+ or Python 3.4+ system. If not, please file an issue <https://github.com/wolfhong/formic/issues/new>
_. Yet not tested on other Python version.
Formic has no runtime dependencies outside the Python system libraries.
Formic can be installed from the Cheeseshop with easy_install::
$ easy_install formic2
Or pip::
$ pip install formic2
Once installed, you can use Formic either from the command line to find from the current directory::
$ formic -i ".py" -e "init.py" "**/test/" "test_"
This will search for files all Python files under the current directory
excluding all __init__.py
files, any file in directories whose name contains
the word 'test', and any files that start test_
.
You can also find from the specified directory like below::
$ formic /specified/directory/can/ignore/ -i ".py" "/test//.txt" "*.ini"
Output from Formic is formatted like the Unix find command, and so can easily be combined with other executables, eg::
$ formic -i "**/*.bak" | xargs rm
will delete all .bak
files in or under the current directory (but excluding VCS directories such as .svn
and .hg
).
Formic can also be integrated right into your Python project::
import formic
fileset = formic.FileSet(include="**.py",
exclude=["**/*test*/**", "test_*"],
directory="./",
symlinks=False, )
for file_name in fileset:
# Do something with file_name
...
Formic is always case-insensitive on NT, but can be either case-sensitive or case-insensitive on POSIX.
On NT::
$ formic ./test/ -i "upp*" "upp*/"
/some/where/formic/test/lower/UPPER.txt
/some/where/formic/test/UPPER/lower.txt
/some/where/formic/test/UPPER/UPPER.txt
On POSIX with case-insensitive::
$ formic ./test/ --insensitive -i "upp*" "upp*/"
/some/where/formic/test/lower/UPPER.txt
/some/where/formic/test/UPPER/lower.txt
/some/where/formic/test/UPPER/UPPER.txt
with case-sensitive::
$ formic ./test/ -i "upp*" "upp*/"
$
That's about it :)
Formic is a Python implementation of Apache Ant FileSet and Globs <http://ant.apache.org/manual/dirtasks.html#patterns>
_ including the directory wildcard **
.
FileSet provides a terse way of specifying a set of files without having to enumerate individual files. It:
Ant Globs are a superset of ordinary file system globs. The key differences:
/root/myapp/*.py
/root/**/*.py
matches
/root/one/two/my.py
/root/**
, or**/parent/*.py
, or**/test/**/*.py
This approach is the de-facto standard in several other languages and tools, including Apache Ant and Maven, Ruby (Dir) and Perforce (...).
Python has built-in support for simple globs in fnmatcher <http://docs.python.org/library/fnmatch.html>
_ and glob <http://docs.python.org/library/glob.html>
_, but Formic:
Can recursively scan subdirectories
Matches arbitrary directories in the path (eg /1/**/2/**/3/**/*.py
).
Has a high level interface:
__pycache__
.Is more efficient with many common patterns; it runs relatively faster on large directory trees with large numbers of files.
Formic is originally written and maintained by Andrew Alcock <mailto:formic@aviser.asia>
_ of Aviser LLP <http://www.aviser.asia>
_, Singapore.
But now, I forked it on GitHub and will maintain this project voluntarily for a long time.
Origin Homepage <http://www.aviser.asia/formic>
_Current Issue tracker <https://github.com/wolfhong/formic/issues?status=new&status=open>
_Current Source <https://github.com/wolfhong/formic>
_ on GitHubPyPI <https://pypi.python.org/pypi/formic2>
_ReadTheDocs <https://formic.readthedocs.io/>
_FAQs
An implementation of Apache Ant FileSet and Globs
We found that formic2 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.