Skip to content

Commit

Permalink
Merge pull request #282 from SAP/bump/hyperscan
Browse files Browse the repository at this point in the history
Bump hyperscan dependency
  • Loading branch information
marcorosa authored Nov 23, 2023
2 parents 28e37cf + a15d281 commit d27d000
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 35 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ jobs:

strategy:
matrix:
#python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9']
python-version: ['3.8', '3.9', '3.10']

services:
postgres:
Expand Down Expand Up @@ -44,7 +43,7 @@ jobs:

- name: Install OS dependencies
run: |
sudo apt install -y build-essential python3-dev libhyperscan-dev
sudo apt install -y build-essential python3-dev
- name: Cache python dependencies
uses: actions/cache@v3
Expand All @@ -54,14 +53,13 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
- name: Install python dependencies
- name: Install credentialdigger
run: |
pip install -r ./requirements.txt
pip install -r ./tests/tests-requirements.txt
pip install . --user
- name: Install credentialdigger
- name: Install tests dependencies
run: |
python setup.py install --user
pip install -r ./tests/tests-requirements.txt
- name: Run unit tests
run: |
Expand Down
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ The goal of Credential Digger is to reduce the amount of false positive data on


The tool supports several scan flavors: public and private repositories on
github and gitlab, wiki pages, github organizations, local git repositories, local files and folders.
github and gitlab, pull requests, wiki pages, github organizations, local git repositories, local files and folders.
Please refer to the [Wiki](https://github.com/SAP/credential-digger/wiki) for the complete documentation.

For the complete description of the approach of Credential Digger, [you can read this publication](https://www.scitepress.org/Papers/2021/102381/102381.pdf).
For the complete description of the approach of Credential Digger (versions <4.4), [you can read this publication](https://www.scitepress.org/Papers/2021/102381/102381.pdf).

```
@InProceedings {lrnto-icissp21,
Expand All @@ -65,22 +65,16 @@ For the complete description of the approach of Credential Digger, [you can read

## Requirements

Credential Digger supports Python >= 3.6 and < 3.10, and works only with Linux and MacOS systems.
Credential Digger supports Python >= 3.8 and < 3.12, and works only with Linux and MacOS systems.
In case you don't meet these requirements, you may consider running a [Docker container](#docker) (that also includes a user interface).


## Download and Installation

First, you need to install the regular expression matching library [Hyperscan](https://github.com/intel/hyperscan). Be sure to have `build-essential` and `python3-dev` too.
First, you need to install some dependencies (namely, `build-essential` and `python3-dev`). No need to explicitely install hyperscan anymore.

```bash
sudo apt install -y libhyperscan-dev build-essential python3-dev
```

or (for MacOS):

```bash
brew install hyperscan
sudo apt install -y build-essential python3-dev
```

Then, you can install Credential Digger module using `pip`.
Expand Down Expand Up @@ -124,9 +118,17 @@ credentialdigger scan https://github.com/user/repo --sqlite /path/to/data.db --s

## Docker container

To have a ready-to-use instance of Credential Digger, with a user interface, you can build the docker container.
To have a ready-to-use instance of Credential Digger, with a user interface, you can use a docker container.
This option requires the installation of [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/).

Credential Digger is published on [dockerhub](https://hub.docker.com/r/saposs/credentialdigger). You can pull the latest release

```bash
sudo docker pull saposs/credentialdigger
```

Or build and run containers with docker-compose

```bash
git clone https://github.com/SAP/credential-digger.git
cd credential-digger
Expand Down Expand Up @@ -157,11 +159,10 @@ git clone https://github.com/SAP/credential-digger.git
cd credential-digger
```

Install the requirements from `requirements.txt` file and install the library:
Install the tool from source:

```bash
pip install -r requirements.txt
python setup.py install
pip install .
```

Then, you can add the rules and scan a repository as described above.
Expand Down
3 changes: 1 addition & 2 deletions credentialdigger/scanners/file_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ def scan_file(self, project_root, relative_path, **kwargs):
for row in file_to_scan:
rh = ResultHandler()
self.stream.scan(
row if sys.version_info < (3, 8) else row.encode(
'utf-8'),
row.encode('utf-8'),
match_event_handler=rh.handle_results,
context=[row.strip(), relative_path, commit_id,
line_number]
Expand Down
2 changes: 1 addition & 1 deletion credentialdigger/scanners/git_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def _regex_check(self, printable_diff, filename, commit_hash):

rh = ResultHandler()
self.stream.scan(
row if sys.version_info < (3, 8) else row.encode('utf-8'),
row.encode('utf-8'),
match_event_handler=rh.handle_results,
context=[row, filename, commit_hash, line_number])
if rh.result:
Expand Down
16 changes: 8 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Flask
flask_jwt_extended
GitPython
hyperscan==0.2.0; python_version >= "3.8"
hyperscan==0.1.5; python_version < "3.8"
hyperscan==0.6.0; python_version != "3.9"
hyperscan==0.5.0; python_version == "3.9"
numpy
pandas
psycopg2-binary
Expand All @@ -11,11 +11,11 @@ python-dotenv
pyyaml
rich~=12.2
srsly>=2.4.0
tensorflow==2.11.1; python_version >= "3.8"
tensorflow~=2.4; python_version < "3.8"
tensorflow-estimator==2.11.0; python_version >= "3.8"
tensorflow-estimator~=2.4; python_version < "3.8"
tensorflow-text==2.11.0; python_version >= "3.8"
tensorflow-text~=2.4; python_version < "3.8"
tensorflow==2.14.0; python_version > "3.8"
tensorflow==2.13.1; python_version <= "3.8"
tensorflow-estimator==2.14.0; python_version > "3.8"
tensorflow-estimator==2.13.0; python_version <= "3.8"
tensorflow-text==2.14.0; python_version > "3.8"
tensorflow-text==2.13.0; python_version <= "3.8"
tf-models-official
transformers
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def requirements():
'Programming Language :: Python :: 3',
'Operating System :: OS Independent',
],
python_requires='>3.5, <3.11',
python_requires='>3.7, <3.12',
entry_points={'console_scripts': ['credentialdigger=credentialdigger'
'.__main__:main']},
)

0 comments on commit d27d000

Please sign in to comment.