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

Add sca signature, change package name format #118

Merged
merged 2 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ on:
- '**.json'
- 'LICENSE'
- '.gitignore'
pull_request:
branches: [ master ]
paths-ignore:
- '.github/**'
- '**.md'
- '**.yml'
- '**.json'
- 'LICENSE'
- '.gitignore'
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '30 1 * * 0'
pull_request:
branches: [ master ]
paths-ignore:
- '.github/**'
- '**.md'
- '**.yml'
- '**.json'
- 'LICENSE'
- '.gitignore'
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '30 1 * * 0'

jobs:
CodeQL-Build:
Expand All @@ -54,8 +54,8 @@ jobs:
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
with:
languages: python, c
with:
languages: python

- name: Set up Python
uses: actions/setup-python@v2
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/vul-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ jobs:
run: |
curl --fail --retry-delay 10 --retry 30 --retry-connrefused http://127.0.0.1:8003/api/django/demo/get_open?name=Data
cd ${{ github.workspace }}/DockerVulspace
docker-compose exec -T djangoweb python -V
docker-compose exec -T djangoweb pip list
docker-compose exec -T flaskweb python -V
docker-compose exec -T flaskweb pip list
docker-compose logs djangoweb flaskweb
bash ${{ github.workspace }}/DongTai-agent-python/dongtai_agent_python/tests/vul-test.sh \
django http://127.0.0.1:8003/api/django ${{ github.run_id }}
Expand Down
6 changes: 3 additions & 3 deletions dongtai_agent_python/assess_ext/patch/cast.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ PyObject *unicode_cast_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)

int apply_cast_patch(funchook_t *funchook) {
bytes_cast_origin = (void *)PyBytes_Type.tp_new;
funchook_prepare_wrapper(funchook, &bytes_cast_origin, bytes_cast_new);
funchook_prepare_wrapper(funchook, (PyCFunction)&bytes_cast_origin, bytes_cast_new);

bytearray_cast_origin = (void *)PyByteArray_Type.tp_init;
funchook_prepare_wrapper(funchook, &bytearray_cast_origin, bytearray_cast_new);
funchook_prepare_wrapper(funchook, (PyCFunction)&bytearray_cast_origin, bytearray_cast_new);

unicode_cast_origin = (void *)PyUnicode_Type.tp_new;
funchook_prepare_wrapper(funchook, &unicode_cast_origin, unicode_cast_new);
funchook_prepare_wrapper(funchook, (PyCFunction)&unicode_cast_origin, unicode_cast_new);

log_debug("------c_patch------------------ cast");

Expand Down
13 changes: 7 additions & 6 deletions dongtai_agent_python/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,16 @@ def get_packages():
if os.path.exists(package.location + os.sep + lvl):
module_path = package.location + os.sep + lvl

# @TODO: temporary set package signature to blank
# sha_1 = hashlib.sha1()
# sha_1.update(bytes(package.project_name.lower() + '-' + package.version, encoding='utf-8'))
# digest = sha_1.hexdigest()
package_name = 'pypi:' + package.project_name.lower() + ':' + package.version
sha_1 = hashlib.sha1()
sha_1.update(bytes(package_name, encoding='utf-8'))
digest = sha_1.hexdigest()

sca_packages.append({
'packageName': package.project_name + '-' + package.version,
'packageName': package_name,
'packageVersion': package.version,
'packagePath': module_path,
'packageAlgorithm': 'SHA-1',
'packageSignature': '',
'packageSignature': digest,
})
return sca_packages