Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auxiliary #545

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
95 changes: 55 additions & 40 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,23 @@ jobs:
- name: Checkout CredData
uses: actions/checkout@v4
with:
repository: Samsung/CredData
repository: babenek/CredData
ref: auxiliary

- name: Markup hashing
run: |
for f in $(find meta -type f|sort); do md5sum $f; done >meta.md5
md5sum snapshot.yaml >checksums.md5
for f in $(find meta -type f|sort); do md5sum $f; done >>checksums.md5
for f in $(find . -maxdepth 1 -type f -name "*.py"|sort); do md5sum $f; done >>checksums.md5
cat checksums.md5
sha256sum checksums.md5

- name: Cache data
id: cache-data
uses: actions/cache@v4
with:
path: data
key: cred-data-${{ hashFiles('meta.md5') }}
key: cred-data-${{ hashFiles('checksums.md5') }}

- name: Set up Python 3.8
if: steps.cache-data.outputs.cache-hit != 'true'
Expand All @@ -57,6 +62,8 @@ jobs:

run_benchmark:

if: ${{ 'pull_request' == github.event_name }}

needs: [ download_data ]

runs-on: ubuntu-latest
Expand All @@ -66,18 +73,23 @@ jobs:
- name: Checkout CredData
uses: actions/checkout@v4
with:
repository: Samsung/CredData
repository: babenek/CredData
ref: auxiliary

- name: Markup hashing
run: |
for f in $(find meta -type f|sort); do md5sum $f; done >meta.md5
md5sum snapshot.yaml >checksums.md5
for f in $(find meta -type f|sort); do md5sum $f; done >>checksums.md5
for f in $(find . -maxdepth 1 -type f -name "*.py"|sort); do md5sum $f; done >>checksums.md5
cat checksums.md5
sha256sum checksums.md5

- name: Cache data
id: cache-data
uses: actions/cache@v4
with:
path: data
key: cred-data-${{ hashFiles('meta.md5') }}
key: cred-data-${{ hashFiles('checksums.md5') }}

- name: Failure in case when cache missed
if: steps.cache-data.outputs.cache-hit != 'true'
Expand All @@ -99,60 +111,53 @@ jobs:
run: python -m pip install --requirement requirements.txt

- name: Checkout CredSweeper
if: ${{ 'pull_request' == github.event_name }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
path: temp/CredSweeper

- name: Patch benchmark for PR work
if: ${{ 'pull_request' == github.event_name }}
run: |
sed -i 's|CREDSWEEPER = "https://github.com/Samsung/CredSweeper.git"|CREDSWEEPER = "dummy://github.com/Samsung/CredSweeper.git"|' benchmark/common/constants.py
grep --with-filename --line-number 'dummy://github.com/Samsung/CredSweeper.git' benchmark/common/constants.py

- name: Run Benchmark
- name: Install CredSweeper
run: |
python -m benchmark --scanner credsweeper | tee credsweeper.log
python -m pip install temp/CredSweeper
credsweeper_head=

- name: Get only results
- name: Run CredSweeper tool
run: |
head -n 235 credsweeper.log | tee benchmark.txt
tail -n 15 credsweeper.log | grep -v 'Time Elapsed:' | tee -a benchmark.txt
cp -vf ./temp/CredSweeper/output.json report.json
credsweeper --banner --jobs $(nproc) --path data --save-json report.${{ github.event.pull_request.head.sha }}.json | tee credsweeper.${{ github.event.pull_request.head.sha }}.log

- name: Run Benchmark
run: |
python -m benchmark --scanner credsweeper --load report.${{ github.event.pull_request.head.sha }}.json | tee benchmark.${{ github.event.pull_request.head.sha }}.log

- name: Upload CredSweeper log
if: always()
uses: actions/upload-artifact@v4
with:
name: credsweeper
path: credsweeper.${{ github.event.pull_request.head.sha }}.log

- name: Upload artifact
- name: Upload CredSweeper report
if: always()
uses: actions/upload-artifact@v4
with:
name: report
path: report.json
path: report.${{ github.event.pull_request.head.sha }}.json

- name: Upload artifact
- name: Upload benchmark output
if: always()
uses: actions/upload-artifact@v4
with:
name: benchmark
path: benchmark.txt
path: benchmark.${{ github.event.pull_request.head.sha }}.log

- name: Verify benchmark scores of the PR
if: ${{ 'pull_request' == github.event_name }}
# update cicd/benchmark.txt with uploaded artifact if a difference is found
run: |
diff --ignore-all-space --ignore-blank-lines temp/CredSweeper/cicd/benchmark.txt benchmark.txt

- name: Checkout CredSweeper on push event
if: ${{ 'pull_request' != github.event_name }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
path: CredSweeper

- name: Verify benchmark scores on push event
if: ${{ 'pull_request' != github.event_name }}
# update cicd/benchmark.txt with uploaded artifact if a difference is found
run: |
diff --ignore-all-space --ignore-blank-lines CredSweeper/cicd/benchmark.txt benchmark.txt
diff --ignore-all-space --ignore-blank-lines temp/CredSweeper/cicd/benchmark.txt benchmark.${{ github.event.pull_request.head.sha }}.log

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Expand All @@ -171,18 +176,23 @@ jobs:
- name: Checkout CredData
uses: actions/checkout@v4
with:
repository: Samsung/CredData
repository: babenek/CredData
ref: auxiliary

- name: Markup hashing
run: |
for f in $(find meta -type f|sort); do md5sum $f; done >meta.md5
md5sum snapshot.yaml >checksums.md5
for f in $(find meta -type f|sort); do md5sum $f; done >>checksums.md5
for f in $(find . -maxdepth 1 -type f -name "*.py"|sort); do md5sum $f; done >>checksums.md5
cat checksums.md5
sha256sum checksums.md5

- name: Cache data
id: cache-data
uses: actions/cache@v4
with:
path: data
key: cred-data-${{ hashFiles('meta.md5') }}
key: cred-data-${{ hashFiles('checksums.md5') }}

- name: Failure in case when cache missed
if: steps.cache-data.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -348,18 +358,23 @@ jobs:
- name: Checkout CredData
uses: actions/checkout@v4
with:
repository: Samsung/CredData
repository: babenek/CredData
ref: auxiliary

- name: Markup hashing
run: |
for f in $(find meta -type f|sort); do md5sum $f; done >meta.md5
md5sum snapshot.yaml >checksums.md5
for f in $(find meta -type f|sort); do md5sum $f; done >>checksums.md5
for f in $(find . -maxdepth 1 -type f -name "*.py"|sort); do md5sum $f; done >>checksums.md5
cat checksums.md5
sha256sum checksums.md5

- name: Cache data
id: cache-data
uses: actions/cache@v4
with:
path: data
key: cred-data-${{ hashFiles('meta.md5') }}
key: cred-data-${{ hashFiles('checksums.md5') }}

- name: Failure in case when cache missed
if: steps.cache-data.outputs.cache-hit != 'true'
Expand Down
6 changes: 3 additions & 3 deletions credsweeper/rules/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
confidence: moderate
type: pattern
values:
- (?P<variable>[`'\"]?(?i:(?<!id[ :/])pa[as]swo?r?ds?|pwd?|p/w|비밀번호|비번|패스워드|암호)[`'\"]?)((\s)*[=:](\s)*)(?P<quote>[`'\"(])?(?P<value>(?-i:(?P<a>[A-Z])|(?P<b>[a-z])|(?P<c>[0-9/_+=~!@#$%^&*;:?-])){4,31}(?(a)(?(b)(?(c)(\S|$)|(?!x)x)|(?!x)x)|(?!x)x))(?(quote)[)`'\"])
- (?P<variable>[`'\"]?(?i:(?<!id[ :/])pa[as]swo?r?ds?|pwd?|p/w|비밀번호|비번|패스워드|암호)[`'\"]?)((\s)*[=:](\s)*)(?P<quote>[`'\"(])?(?P<value>(?-i:(?P<a>[A-Z])|(?P<b>[a-z])|(?P<c>[0-9/_+=~!@#$%^&*;:?-])){8,31}(?(a)(?(b)(?(c)(\S|$)|(?!x)x)|(?!x)x)|(?!x)x))(?(quote)[)`'\"])
filter_type:
- ValueAllowlistCheck
- ValuePatternCheck
Expand All @@ -54,7 +54,7 @@
confidence: moderate
type: pattern
values:
- (^|\s|(?P<variable>(?i:\bip[\s/]+id[\s/]+pw[\s/:]*))|(?P<url>://))(?P<ip>[0-2]?[0-9]{1,2}\.[0-2]?[0-9]{1,2}\.[0-2]?[0-9]{1,2}\.[0-2]?[0-9]{1,2})((\s*\()?|(?(variable)[\s,/]+|(?(url)[,]|[,/])))\s*\w[\w.-]{3,80}[\s,/]+(?P<value>(?(url)(?-i:(?P<a>[A-Z])|(?P<b>[a-z])|(?P<c>[0-9_+=~!@#$%^&*;?-])){4,31}(?(a)(?(b)(?(c)(\S|$)|(?!x)x)|(?!x)x)|(?!x)x)|(?-i:(?P<e>[A-Z])|(?P<f>[a-z])|(?P<g>[0-9/_+=~!@#$%^&*;?-])){4,31}(?(e)(?(f)(?(g)(\S|$)|(?!x)x)|(?!x)x)|(?!x)x)))(?:\s|[^/]|$)
- (^|\s|(?P<variable>(?i:\bip[\s/]+id[\s/]+pw[\s/:]*))|(?P<url>://))(?P<ip>[0-2]?[0-9]{1,2}\.[0-2]?[0-9]{1,2}\.[0-2]?[0-9]{1,2}\.[0-2]?[0-9]{1,2})((\s*\()?|(?(variable)[\s,/]+|(?(url)[,]|[,/])))\s*\w[\w.-]{3,80}[\s,/]+(?P<value>(?(url)(?-i:(?P<a>[A-Z])|(?P<b>[a-z])|(?P<c>[0-9_+=~!@#$%^&*;?-])){7,31}(?(a)(?(b)(?(c)(\S|$)|(?!x)x)|(?!x)x)|(?!x)x)|(?-i:(?P<e>[A-Z])|(?P<f>[a-z])|(?P<g>[0-9/_+=~!@#$%^&*;?-])){7,31}(?(e)(?(f)(?(g)(\S|$)|(?!x)x)|(?!x)x)|(?!x)x)))(?:\s|[^/]|$)
filter_type:
- ValueAllowlistCheck
- ValuePatternCheck
Expand Down Expand Up @@ -250,7 +250,7 @@
type: multi
values:
- (?P<value>[0-9]{3,80}-[0-9a-z_]{32}\.apps\.googleusercontent\.com)
- \b(?P<value>GOCSPX-[0-9A-Za-z_-]{28}|((?P<a>[A-Z])|(?P<b>[a-z])|(?P<c>[0-9_-])){24}(?(a)(?(b)(?(c)\b|(?!x)x)|(?!x)x)|(?!x)x))
- \b(?P<value>GOCSPX-[0-9A-Za-z_-]{28}|((?P<a>[A-Z])|(?P<b>[a-z])|(?P<c>[0-9_-])){24,80}(?(a)(?(b)(?(c)\b|(?!x)x)|(?!x)x)|(?!x)x))
filter_type: GeneralPattern
validations:
- GoogleMultiValidation
Expand Down
2 changes: 2 additions & 0 deletions tests/samples/doc_ip_id_password_triple
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ ifconfig eth0 192.168.0.1 netmask 255.255.255.0
Service(Standby) ip : 192.168.127.24(23591 port) ip : 192.168.142.42(21345 port) ip : 192.168.12.23(23827 port)
127.0.0.1/root/OTHER_ETC/job/OTHER_CPI6_COVERAGE/376/GCOV_32Coverage_32Report_12CAPI_42/

FP# [Wi-Fi HotSpot] 5.2.0.299-WR220224U #Wi-Fi

3 changes: 3 additions & 0 deletions tests/samples/doc_passwd_pair
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ FALSE:
# password: keep empty
암호 : @@@hl@@@비번@@@endhl@@@

FP# 10.0.0.1 8888 TLSv1.2