Skip to main content

File system scanner in Python

Project description

scanfs

This module scans the filesystem and provides custom hooks to handle each file type of your choice.

Installation

pip install scanfs

Example

How to write your own scanner enhancements?

This example scans the /usr/bin folder for ELF files and handles the callback to provide file stat info.

import os
from scanfs.fsscanner import FileSystemScanner
from scanfs.fsscannerex import FSScannerException


def callback(fpath, node):
    try:
        path = os.path.join(fpath, node.name)
        # Now do what you want on the instance of file
        # eg. stat
        statinfo = os.stat(path)
        print(statinfo)
    except FSScannerException as e:
        print("An exception occurred: " + str(e))


fss = FileSystemScanner("/usr/bin")
fss.scan_for_elfs(callback)

Simple way to scan ELF files for binary protection check using checksec utility

checksec utility can be downloaded here

import os
import subprocess
from scanfs.fsscanner import FileSystemScanner
from scanfs.scanners.checksecscanner import CheckSecScanner

css = CheckSecScanner("/usr/bin", "/tmp/checksec_results.json")
css.checksec_on_elfs()

css = CheckSecScanner("/usr/bin", "/tmp/checksec_results.csv", fformat="csv")
css.checksec_on_elfs()

Developer

python -m build
twine upload dist/*

Ref: https://packaging.python.org/tutorials/packaging-projects/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scanfs-0.0.6.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

scanfs-0.0.6-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file scanfs-0.0.6.tar.gz.

File metadata

  • Download URL: scanfs-0.0.6.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.3

File hashes

Hashes for scanfs-0.0.6.tar.gz
Algorithm Hash digest
SHA256 282bf4968e1cdd719d7da8e79a516ba8b4e186f9fc06f753f625db6c314fa5cd
MD5 ca9c2002a8830601b3a3cbdd7ef601c3
BLAKE2b-256 0f66937cc8e5e8519656a7cb1972ae3576f74bce47eedce02caf13f37a74e443

See more details on using hashes here.

File details

Details for the file scanfs-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: scanfs-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.3

File hashes

Hashes for scanfs-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e7accd27b0d4e80b8cff6c5b59032c89b1e86c2009f2b9a1a055cbba3fbd51b8
MD5 1947d780cebd655f98679921ae894fe5
BLAKE2b-256 07058078c2a83d809e1177bbc1acd9e094125b678d0b90d0a18d874486580ccb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page