damlisk 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- damlisk-0.0.1/.github/workflows/ci.yml +32 -0
- damlisk-0.0.1/.github/workflows/workflow.yml +66 -0
- damlisk-0.0.1/.gitignore +39 -0
- damlisk-0.0.1/LICENSE +201 -0
- damlisk-0.0.1/Makefile +91 -0
- damlisk-0.0.1/PKG-INFO +215 -0
- damlisk-0.0.1/README.md +183 -0
- damlisk-0.0.1/damlisk/__init__.py +21 -0
- damlisk-0.0.1/damlisk/__main__.py +7 -0
- damlisk-0.0.1/damlisk/cli/__init__.py +0 -0
- damlisk-0.0.1/damlisk/cli/main.py +130 -0
- damlisk-0.0.1/damlisk/damlisk_git_commithash.txt +1 -0
- damlisk-0.0.1/damlisk/detectors/__init__.py +0 -0
- damlisk-0.0.1/damlisk/detectors/abstract_detector.py +49 -0
- damlisk-0.0.1/damlisk/detectors/all_detectors.py +74 -0
- damlisk-0.0.1/damlisk/detectors/assets/__init__.py +0 -0
- damlisk-0.0.1/damlisk/detectors/assets/arbitrary_party.py +72 -0
- damlisk-0.0.1/damlisk/detectors/assets/stuck_asset.py +68 -0
- damlisk-0.0.1/damlisk/detectors/authorization/__init__.py +0 -0
- damlisk-0.0.1/damlisk/detectors/authorization/controller_arg.py +50 -0
- damlisk-0.0.1/damlisk/detectors/authorization/delegated_leak.py +129 -0
- damlisk-0.0.1/damlisk/detectors/authorization/hardcoded_party.py +105 -0
- damlisk-0.0.1/damlisk/detectors/authorization/over_disclosure.py +49 -0
- damlisk-0.0.1/damlisk/detectors/authorization/unprotected_archive.py +51 -0
- damlisk-0.0.1/damlisk/detectors/contracts/__init__.py +0 -0
- damlisk-0.0.1/damlisk/detectors/contracts/stale_fetch.py +168 -0
- damlisk-0.0.1/damlisk/detectors/contracts/unsafe_primitive.py +63 -0
- damlisk-0.0.1/damlisk/detectors/contracts/untrusted_interface.py +90 -0
- damlisk-0.0.1/damlisk/detectors/hygiene/__init__.py +0 -0
- damlisk-0.0.1/damlisk/detectors/hygiene/aborting_choice.py +101 -0
- damlisk-0.0.1/damlisk/detectors/hygiene/boolean_cst.py +74 -0
- damlisk-0.0.1/damlisk/detectors/hygiene/boolean_equal.py +47 -0
- damlisk-0.0.1/damlisk/detectors/hygiene/debug_trace.py +39 -0
- damlisk-0.0.1/damlisk/detectors/hygiene/discarded_update.py +57 -0
- damlisk-0.0.1/damlisk/detectors/hygiene/rtlo.py +75 -0
- damlisk-0.0.1/damlisk/detectors/hygiene/tautological_compare.py +67 -0
- damlisk-0.0.1/damlisk/detectors/hygiene/unused_field.py +126 -0
- damlisk-0.0.1/damlisk/detectors/loops/__init__.py +0 -0
- damlisk-0.0.1/damlisk/detectors/loops/ledger_op_in_loop.py +116 -0
- damlisk-0.0.1/damlisk/detectors/loops/unbounded_input_loop.py +58 -0
- damlisk-0.0.1/damlisk/detectors/time/__init__.py +0 -0
- damlisk-0.0.1/damlisk/detectors/time/time_dependence.py +44 -0
- damlisk-0.0.1/damlisk/detectors/time/weak_randomness.py +57 -0
- damlisk-0.0.1/damlisk/detectors/upgrade/__init__.py +0 -0
- damlisk-0.0.1/damlisk/detectors/upgrade/sdk_version.py +34 -0
- damlisk-0.0.1/damlisk/detectors/validation/__init__.py +0 -0
- damlisk-0.0.1/damlisk/detectors/validation/amount_tolerance.py +61 -0
- damlisk-0.0.1/damlisk/detectors/validation/divide_multiply.py +74 -0
- damlisk-0.0.1/damlisk/detectors/validation/hash_concat.py +107 -0
- damlisk-0.0.1/damlisk/detectors/validation/ignored_optional.py +79 -0
- damlisk-0.0.1/damlisk/detectors/validation/missing_amount.py +54 -0
- damlisk-0.0.1/damlisk/detectors/validation/missing_ensure.py +66 -0
- damlisk-0.0.1/damlisk/detectors/validation/nonconsuming_create.py +53 -0
- damlisk-0.0.1/damlisk/detectors/validation/partial_function.py +53 -0
- damlisk-0.0.1/damlisk/detectors/validation/time_argument.py +71 -0
- damlisk-0.0.1/damlisk/detectors/validation/time_equality.py +79 -0
- damlisk-0.0.1/damlisk/detectors/validation/unchecked_fetch.py +54 -0
- damlisk-0.0.1/damlisk/detectors/validation/unconsumed_input.py +70 -0
- damlisk-0.0.1/damlisk/exceptions.py +6 -0
- damlisk-0.0.1/damlisk/lf/__init__.py +0 -0
- damlisk-0.0.1/damlisk/lf/builtins.py +418 -0
- damlisk-0.0.1/damlisk/lf/dar.py +111 -0
- damlisk-0.0.1/damlisk/lf/flow.py +525 -0
- damlisk-0.0.1/damlisk/lf/index.py +319 -0
- damlisk-0.0.1/damlisk/lf/lf2.py +149 -0
- damlisk-0.0.1/damlisk/lf/tree.py +88 -0
- damlisk-0.0.1/damlisk/output/__init__.py +0 -0
- damlisk-0.0.1/damlisk/output/finding.py +67 -0
- damlisk-0.0.1/damlisk/output/formats.py +15 -0
- damlisk-0.0.1/damlisk/version.py +4 -0
- damlisk-0.0.1/damlisk.egg-info/PKG-INFO +215 -0
- damlisk-0.0.1/damlisk.egg-info/SOURCES.txt +204 -0
- damlisk-0.0.1/damlisk.egg-info/dependency_links.txt +1 -0
- damlisk-0.0.1/damlisk.egg-info/entry_points.txt +2 -0
- damlisk-0.0.1/damlisk.egg-info/requires.txt +3 -0
- damlisk-0.0.1/damlisk.egg-info/top_level.txt +1 -0
- damlisk-0.0.1/docs/detectors/01-authorization.md +345 -0
- damlisk-0.0.1/docs/detectors/02-assets.md +146 -0
- damlisk-0.0.1/docs/detectors/03-contracts.md +219 -0
- damlisk-0.0.1/docs/detectors/04-validation.md +646 -0
- damlisk-0.0.1/docs/detectors/05-time.md +134 -0
- damlisk-0.0.1/docs/detectors/06-loops.md +126 -0
- damlisk-0.0.1/docs/detectors/07-hygiene.md +466 -0
- damlisk-0.0.1/docs/detectors/08-upgrade.md +34 -0
- damlisk-0.0.1/docs/logo.svg +35 -0
- damlisk-0.0.1/examples/vulnerable/aborting-choice/daml/Main.daml +38 -0
- damlisk-0.0.1/examples/vulnerable/aborting-choice/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/amount-tolerance/daml/Main.daml +45 -0
- damlisk-0.0.1/examples/vulnerable/amount-tolerance/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/boolean-cst/daml/Main.daml +51 -0
- damlisk-0.0.1/examples/vulnerable/boolean-cst/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/boolean-equal/daml/Main.daml +40 -0
- damlisk-0.0.1/examples/vulnerable/boolean-equal/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/controller-from-argument/daml/Main.daml +58 -0
- damlisk-0.0.1/examples/vulnerable/controller-from-argument/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/debug-trace/daml/Main.daml +41 -0
- damlisk-0.0.1/examples/vulnerable/debug-trace/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/delegated-authority-leak/daml/Main.daml +134 -0
- damlisk-0.0.1/examples/vulnerable/delegated-authority-leak/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/discarded-update/daml/Main.daml +55 -0
- damlisk-0.0.1/examples/vulnerable/discarded-update/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/divide-before-multiply/daml/Main.daml +40 -0
- damlisk-0.0.1/examples/vulnerable/divide-before-multiply/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/hardcoded-party/daml/Main.daml +36 -0
- damlisk-0.0.1/examples/vulnerable/hardcoded-party/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/hash-concat-collision/daml/Main.daml +51 -0
- damlisk-0.0.1/examples/vulnerable/hash-concat-collision/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/ignored-optional/daml/Main.daml +69 -0
- damlisk-0.0.1/examples/vulnerable/ignored-optional/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/ledger-op-in-loop/daml/Main.daml +84 -0
- damlisk-0.0.1/examples/vulnerable/ledger-op-in-loop/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/missing-amount-check/daml/Main.daml +45 -0
- damlisk-0.0.1/examples/vulnerable/missing-amount-check/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/missing-ensure/daml/Main.daml +38 -0
- damlisk-0.0.1/examples/vulnerable/missing-ensure/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/nonconsuming-create/daml/Main.daml +56 -0
- damlisk-0.0.1/examples/vulnerable/nonconsuming-create/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/over-disclosure/daml/Main.daml +38 -0
- damlisk-0.0.1/examples/vulnerable/over-disclosure/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/partial-function/daml/Main.daml +35 -0
- damlisk-0.0.1/examples/vulnerable/partial-function/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/rtlo/daml/Main.daml +24 -0
- damlisk-0.0.1/examples/vulnerable/rtlo/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/stale-fetch/daml/Main.daml +93 -0
- damlisk-0.0.1/examples/vulnerable/stale-fetch/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/stuck-asset/daml/Main.daml +58 -0
- damlisk-0.0.1/examples/vulnerable/stuck-asset/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/tautological-compare/daml/Main.daml +44 -0
- damlisk-0.0.1/examples/vulnerable/tautological-compare/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/time-dependence/daml/Main.daml +77 -0
- damlisk-0.0.1/examples/vulnerable/time-dependence/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/time-equality/daml/Main.daml +41 -0
- damlisk-0.0.1/examples/vulnerable/time-equality/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/time-from-argument/daml/Main.daml +45 -0
- damlisk-0.0.1/examples/vulnerable/time-from-argument/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/unbounded-input-loop/daml/Main.daml +81 -0
- damlisk-0.0.1/examples/vulnerable/unbounded-input-loop/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/unchecked-fetch/daml/Main.daml +66 -0
- damlisk-0.0.1/examples/vulnerable/unchecked-fetch/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/unconsumed-input/daml/Main.daml +59 -0
- damlisk-0.0.1/examples/vulnerable/unconsumed-input/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/unprotected-archive/daml/Main.daml +30 -0
- damlisk-0.0.1/examples/vulnerable/unprotected-archive/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/unsafe-primitive/daml/Main.daml +60 -0
- damlisk-0.0.1/examples/vulnerable/unsafe-primitive/daml.yaml +10 -0
- damlisk-0.0.1/examples/vulnerable/untrusted-interface-exercise/daml/Main.daml +124 -0
- damlisk-0.0.1/examples/vulnerable/untrusted-interface-exercise/daml.yaml +10 -0
- damlisk-0.0.1/examples/vulnerable/unused-template-field/daml/Main.daml +37 -0
- damlisk-0.0.1/examples/vulnerable/unused-template-field/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/value-to-arbitrary-party/daml/Main.daml +145 -0
- damlisk-0.0.1/examples/vulnerable/value-to-arbitrary-party/daml.yaml +9 -0
- damlisk-0.0.1/examples/vulnerable/weak-randomness/daml/Main.daml +95 -0
- damlisk-0.0.1/examples/vulnerable/weak-randomness/daml.yaml +9 -0
- damlisk-0.0.1/flake.lock +61 -0
- damlisk-0.0.1/flake.nix +23 -0
- damlisk-0.0.1/pyproject.toml +82 -0
- damlisk-0.0.1/scripts/fetch_dars.py +93 -0
- damlisk-0.0.1/setup.cfg +16 -0
- damlisk-0.0.1/setup.py +65 -0
- damlisk-0.0.1/tests/__init__.py +0 -0
- damlisk-0.0.1/tests/cli/__init__.py +0 -0
- damlisk-0.0.1/tests/cli/test_main.py +87 -0
- damlisk-0.0.1/tests/conftest.py +255 -0
- damlisk-0.0.1/tests/detectors/__init__.py +0 -0
- damlisk-0.0.1/tests/detectors/test_aborting_choice.py +90 -0
- damlisk-0.0.1/tests/detectors/test_amount_tolerance.py +81 -0
- damlisk-0.0.1/tests/detectors/test_arbitrary_party.py +78 -0
- damlisk-0.0.1/tests/detectors/test_boolean_cst.py +71 -0
- damlisk-0.0.1/tests/detectors/test_boolean_equal.py +69 -0
- damlisk-0.0.1/tests/detectors/test_controller_arg.py +48 -0
- damlisk-0.0.1/tests/detectors/test_debug_trace.py +37 -0
- damlisk-0.0.1/tests/detectors/test_delegated_leak.py +145 -0
- damlisk-0.0.1/tests/detectors/test_discarded_update.py +55 -0
- damlisk-0.0.1/tests/detectors/test_divide_multiply.py +84 -0
- damlisk-0.0.1/tests/detectors/test_hardcoded_party.py +82 -0
- damlisk-0.0.1/tests/detectors/test_hash_concat.py +135 -0
- damlisk-0.0.1/tests/detectors/test_ignored_optional.py +102 -0
- damlisk-0.0.1/tests/detectors/test_ledger_op_in_loop.py +86 -0
- damlisk-0.0.1/tests/detectors/test_missing_amount.py +59 -0
- damlisk-0.0.1/tests/detectors/test_missing_ensure.py +56 -0
- damlisk-0.0.1/tests/detectors/test_nonconsuming_create.py +55 -0
- damlisk-0.0.1/tests/detectors/test_over_disclosure.py +49 -0
- damlisk-0.0.1/tests/detectors/test_partial_function.py +57 -0
- damlisk-0.0.1/tests/detectors/test_rtlo.py +49 -0
- damlisk-0.0.1/tests/detectors/test_sdk_version.py +50 -0
- damlisk-0.0.1/tests/detectors/test_stale_fetch.py +107 -0
- damlisk-0.0.1/tests/detectors/test_stuck_asset.py +56 -0
- damlisk-0.0.1/tests/detectors/test_tautological_compare.py +75 -0
- damlisk-0.0.1/tests/detectors/test_time_argument.py +54 -0
- damlisk-0.0.1/tests/detectors/test_time_dependence.py +68 -0
- damlisk-0.0.1/tests/detectors/test_time_equality.py +93 -0
- damlisk-0.0.1/tests/detectors/test_unbounded_input_loop.py +76 -0
- damlisk-0.0.1/tests/detectors/test_unchecked_fetch.py +37 -0
- damlisk-0.0.1/tests/detectors/test_unconsumed_input.py +59 -0
- damlisk-0.0.1/tests/detectors/test_unprotected_archive.py +49 -0
- damlisk-0.0.1/tests/detectors/test_unsafe_primitive.py +68 -0
- damlisk-0.0.1/tests/detectors/test_untrusted_interface.py +130 -0
- damlisk-0.0.1/tests/detectors/test_unused_field.py +78 -0
- damlisk-0.0.1/tests/detectors/test_weak_randomness.py +63 -0
- damlisk-0.0.1/tests/lf/__init__.py +0 -0
- damlisk-0.0.1/tests/lf/test_dar.py +68 -0
- damlisk-0.0.1/tests/lf/test_flow.py +572 -0
- damlisk-0.0.1/tests/lf/test_index.py +112 -0
- damlisk-0.0.1/tests/lf/test_lf2.py +587 -0
- damlisk-0.0.1/tests/lf/test_tree.py +78 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
|
|
6
|
+
permissions:
|
|
7
|
+
contents: read
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0
|
|
16
|
+
|
|
17
|
+
- uses: cachix/install-nix-action@v31
|
|
18
|
+
with:
|
|
19
|
+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
|
20
|
+
|
|
21
|
+
- uses: actions/cache@v4
|
|
22
|
+
with:
|
|
23
|
+
path: |
|
|
24
|
+
~/.dpm
|
|
25
|
+
examples/dars
|
|
26
|
+
key: dars-${{ runner.os }}-${{ hashFiles('Makefile', 'scripts/fetch_dars.py') }}
|
|
27
|
+
restore-keys: dars-${{ runner.os }}-
|
|
28
|
+
|
|
29
|
+
- name: Build DARs, lint and test
|
|
30
|
+
env:
|
|
31
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
32
|
+
run: nix develop --command make ci
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*.*.*'
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
with:
|
|
17
|
+
fetch-depth: 0
|
|
18
|
+
|
|
19
|
+
- name: Version from tag
|
|
20
|
+
run: |
|
|
21
|
+
VERSION="${GITHUB_REF_NAME#v}"
|
|
22
|
+
if ! echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+((a|b|rc)[0-9]+|\.post[0-9]+|\.dev[0-9]+)?$'; then
|
|
23
|
+
echo "Invalid PEP 440 version: $VERSION"
|
|
24
|
+
exit 1
|
|
25
|
+
fi
|
|
26
|
+
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
|
|
27
|
+
|
|
28
|
+
- uses: actions/setup-python@v5
|
|
29
|
+
with:
|
|
30
|
+
python-version: '3.12'
|
|
31
|
+
|
|
32
|
+
- name: Install build tooling
|
|
33
|
+
run: python -m pip install --upgrade pip build twine
|
|
34
|
+
|
|
35
|
+
- name: Build sdist and wheel
|
|
36
|
+
run: SETUPTOOLS_SCM_PRETEND_VERSION="$VERSION" python -m build
|
|
37
|
+
|
|
38
|
+
- name: Verify package metadata
|
|
39
|
+
run: twine check --strict dist/*
|
|
40
|
+
|
|
41
|
+
- name: Verify damlisk --version
|
|
42
|
+
run: |
|
|
43
|
+
python -m pip install dist/*.whl
|
|
44
|
+
test "$(damlisk --version)" = "damlisk, version $VERSION"
|
|
45
|
+
|
|
46
|
+
- uses: actions/upload-artifact@v4
|
|
47
|
+
with:
|
|
48
|
+
name: damlisk-${{ env.VERSION }}
|
|
49
|
+
path: dist/*
|
|
50
|
+
|
|
51
|
+
publish:
|
|
52
|
+
needs: build
|
|
53
|
+
runs-on: ubuntu-latest
|
|
54
|
+
environment:
|
|
55
|
+
name: pypi
|
|
56
|
+
url: https://pypi.org/project/damlisk/
|
|
57
|
+
permissions:
|
|
58
|
+
id-token: write
|
|
59
|
+
steps:
|
|
60
|
+
- uses: actions/download-artifact@v4
|
|
61
|
+
with:
|
|
62
|
+
path: dist/
|
|
63
|
+
merge-multiple: true
|
|
64
|
+
|
|
65
|
+
- name: Publish to PyPI
|
|
66
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
damlisk-0.0.1/.gitignore
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*$py.class
|
|
4
|
+
|
|
5
|
+
build/
|
|
6
|
+
.eggs/
|
|
7
|
+
dist/
|
|
8
|
+
*.egg-info/
|
|
9
|
+
|
|
10
|
+
.pytest_cache/
|
|
11
|
+
.python-version
|
|
12
|
+
.env
|
|
13
|
+
|
|
14
|
+
.venv/
|
|
15
|
+
venv/
|
|
16
|
+
ENV/
|
|
17
|
+
uv.lock
|
|
18
|
+
|
|
19
|
+
.coverage*
|
|
20
|
+
.cache/
|
|
21
|
+
htmlcov/
|
|
22
|
+
coverage.xml
|
|
23
|
+
|
|
24
|
+
.idea/
|
|
25
|
+
.vscode/
|
|
26
|
+
.tox/
|
|
27
|
+
.mypy_cache/
|
|
28
|
+
|
|
29
|
+
damlisk/version.py
|
|
30
|
+
damlisk/damlisk_git_commithash.txt
|
|
31
|
+
|
|
32
|
+
.DS_Store
|
|
33
|
+
|
|
34
|
+
examples/**/.daml/
|
|
35
|
+
examples/dars/
|
|
36
|
+
examples/vulnerable/**/*.dar
|
|
37
|
+
.claude/*
|
|
38
|
+
*.puml
|
|
39
|
+
checks-feasibility.md
|
damlisk-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
damlisk-0.0.1/Makefile
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
VERSION ?= 0.0.1
|
|
2
|
+
PYTHON ?= python3
|
|
3
|
+
|
|
4
|
+
DARS_REF ?= main
|
|
5
|
+
DARS_ONLY ?=
|
|
6
|
+
DPM ?= $(shell command -v dpm || echo $(HOME)/.dpm/bin/dpm)
|
|
7
|
+
DAML_SDK ?= 3.4.8
|
|
8
|
+
VENV ?= .venv
|
|
9
|
+
|
|
10
|
+
.PHONY: ci dpm dars init dev-init test lint mypy black flake8 isort build dev dev-release release clean clean-pyc clean-build clean-test
|
|
11
|
+
|
|
12
|
+
init:
|
|
13
|
+
$(PYTHON) setup.py install
|
|
14
|
+
|
|
15
|
+
dev-init:
|
|
16
|
+
$(PYTHON) -m pip install -e . --group dev
|
|
17
|
+
|
|
18
|
+
ci:
|
|
19
|
+
$(PYTHON) -m venv $(VENV)
|
|
20
|
+
$(VENV)/bin/pip install -q -U pip
|
|
21
|
+
$(VENV)/bin/pip install -q -e . --group dev
|
|
22
|
+
$(MAKE) dpm dars PYTHON=$(VENV)/bin/python
|
|
23
|
+
PATH="$(CURDIR)/$(VENV)/bin:$$PATH" $(MAKE) lint test
|
|
24
|
+
git diff --exit-code -- damlisk tests setup.py
|
|
25
|
+
|
|
26
|
+
dpm:
|
|
27
|
+
[ -x "$(DPM)" ] || curl -sSL https://get.digitalasset.com/install/install.sh | sh
|
|
28
|
+
$(DPM) install $(DAML_SDK)
|
|
29
|
+
|
|
30
|
+
dars:
|
|
31
|
+
$(PYTHON) scripts/fetch_dars.py --out examples/dars --ref $(DARS_REF) --only "$(DARS_ONLY)"
|
|
32
|
+
@for dir in examples/vulnerable/*/; do \
|
|
33
|
+
name=$$(basename $$dir); \
|
|
34
|
+
echo "building $$name"; \
|
|
35
|
+
log=$$(cd $$dir && $(DPM) build -o $$name.dar 2>&1) || { echo "$$log"; exit 1; }; \
|
|
36
|
+
rm -rf $$dir.daml; \
|
|
37
|
+
done
|
|
38
|
+
|
|
39
|
+
test:
|
|
40
|
+
pytest
|
|
41
|
+
|
|
42
|
+
lint: mypy black flake8 isort
|
|
43
|
+
|
|
44
|
+
mypy:
|
|
45
|
+
mypy -p damlisk
|
|
46
|
+
|
|
47
|
+
black:
|
|
48
|
+
black damlisk/ tests/ setup.py
|
|
49
|
+
|
|
50
|
+
flake8: black
|
|
51
|
+
flake8 damlisk/ tests/
|
|
52
|
+
|
|
53
|
+
isort: black
|
|
54
|
+
isort damlisk/ tests/ setup.py
|
|
55
|
+
|
|
56
|
+
build: clean
|
|
57
|
+
$(PYTHON) -m build
|
|
58
|
+
ls -la dist/
|
|
59
|
+
|
|
60
|
+
dev:
|
|
61
|
+
SETUPTOOLS_SCM_PRETEND_VERSION=$(VERSION) $(MAKE) build
|
|
62
|
+
|
|
63
|
+
dev-release:
|
|
64
|
+
SETUPTOOLS_SCM_PRETEND_VERSION=$(VERSION) \
|
|
65
|
+
$(PYTHON) -m pip install --no-deps --force-reinstall -e .
|
|
66
|
+
|
|
67
|
+
release: build
|
|
68
|
+
twine check dist/*
|
|
69
|
+
|
|
70
|
+
clean: clean-build clean-pyc clean-test
|
|
71
|
+
|
|
72
|
+
clean-build:
|
|
73
|
+
@echo Cleaning python build files...
|
|
74
|
+
@rm -fr build/
|
|
75
|
+
@rm -fr dist/
|
|
76
|
+
@rm -fr *.egg-info
|
|
77
|
+
@rm -f damlisk/version.py damlisk/damlisk_git_commithash.txt
|
|
78
|
+
|
|
79
|
+
clean-pyc:
|
|
80
|
+
@echo Cleaning python files...
|
|
81
|
+
@find . -path ./.venv -prune -o -name '*.pyc' -exec rm -f {} +
|
|
82
|
+
@find . -path ./.venv -prune -o -name '*.pyo' -exec rm -f {} +
|
|
83
|
+
@find . -path ./.venv -prune -o -name '__pycache__' -exec rm -rf {} +
|
|
84
|
+
|
|
85
|
+
clean-test:
|
|
86
|
+
@echo Cleaning test files...
|
|
87
|
+
@find . -path ./.venv -prune -o -name 'htmlcov' -exec rm -rf {} +
|
|
88
|
+
@rm -fr coverage.xml
|
|
89
|
+
@rm -fr .coverage
|
|
90
|
+
@rm -fr .pytest_cache/
|
|
91
|
+
@rm -fr .mypy_cache/
|
damlisk-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: damlisk
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Damlisk: static analyzer for Daml-LF packages (.dar)
|
|
5
|
+
Home-page: https://github.com/DIGIAPP-LLC/damlisk
|
|
6
|
+
Author: Artem
|
|
7
|
+
Author-email: artem@kekpool.com
|
|
8
|
+
Maintainer: DIGIAPP LLC
|
|
9
|
+
Keywords: daml canton daml-lf static analysis security
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Requires-Python: >=3.11,<4
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: dazl>=8.9
|
|
19
|
+
Requires-Dist: click<9,>=8.1
|
|
20
|
+
Requires-Dist: loguru
|
|
21
|
+
Dynamic: author
|
|
22
|
+
Dynamic: author-email
|
|
23
|
+
Dynamic: classifier
|
|
24
|
+
Dynamic: description
|
|
25
|
+
Dynamic: description-content-type
|
|
26
|
+
Dynamic: home-page
|
|
27
|
+
Dynamic: keywords
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
Dynamic: maintainer
|
|
30
|
+
Dynamic: requires-python
|
|
31
|
+
Dynamic: summary
|
|
32
|
+
|
|
33
|
+
<div align="center">
|
|
34
|
+
|
|
35
|
+
<img src="docs/logo.svg" alt="damlisk" width="120">
|
|
36
|
+
|
|
37
|
+
# damlisk
|
|
38
|
+
|
|
39
|
+
**Static analyzer for Daml smart contracts.**
|
|
40
|
+
|
|
41
|
+
[](https://pypi.org/project/damlisk/)
|
|
42
|
+
[](.github/workflows/ci.yml)
|
|
43
|
+
[](setup.py)
|
|
44
|
+
[](LICENSE)
|
|
45
|
+
|
|
46
|
+
[Detectors](#documentation) · [Examples](examples/vulnerable)
|
|
47
|
+
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
damlisk reads the Daml-LF inside a `.dar` through
|
|
51
|
+
[dazl](https://github.com/digital-asset/dazl-client), walks every template, choice and value,
|
|
52
|
+
and runs detectors over it. It needs no Daml source and no running ledger: what damlc
|
|
53
|
+
compiled is what gets checked.
|
|
54
|
+
|
|
55
|
+
## How it works
|
|
56
|
+
|
|
57
|
+
**1. Install damlisk** (Python 3.11 or newer):
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install damlisk
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**2. Build your Daml project** with `dpm build`. This choice uses a fetched value after its
|
|
64
|
+
contract was replaced:
|
|
65
|
+
|
|
66
|
+
```haskell
|
|
67
|
+
nonconsuming choice PayOut : ContractId Receipt
|
|
68
|
+
with
|
|
69
|
+
cid : ContractId Account
|
|
70
|
+
controller owner
|
|
71
|
+
do
|
|
72
|
+
acc <- fetch cid
|
|
73
|
+
_ <- exercise cid Withdraw with amt = 10.0
|
|
74
|
+
create Receipt with bank; owner; remaining = acc.amount
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**3. Scan the DAR:**
|
|
78
|
+
|
|
79
|
+
```text
|
|
80
|
+
$ damlisk scan examples/vulnerable/stale-fetch/stale-fetch.dar --detect stale-fetch
|
|
81
|
+
[Medium] stale-fetch Main.daml:29
|
|
82
|
+
Main:Desk.PayOut: `acc` is used after `Withdraw`
|
|
83
|
+
[Medium] stale-fetch Main.daml:38
|
|
84
|
+
Main:Desk.PayTwice: `acc` is used after `Withdraw`
|
|
85
|
+
2 finding(s).
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Documentation
|
|
89
|
+
|
|
90
|
+
Each page explains its detectors: what they report, why it matters, an example with the
|
|
91
|
+
scan output, and how the check works and what it misses.
|
|
92
|
+
|
|
93
|
+
| # | Page | Detectors |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| 1 | [Authorization](docs/detectors/01-authorization.md) | `controller-from-argument`, `hardcoded-party`, `unprotected-archive`, `over-disclosure`, `delegated-authority-leak` |
|
|
96
|
+
| 2 | [Assets](docs/detectors/02-assets.md) | `stuck-asset`, `value-to-arbitrary-party` |
|
|
97
|
+
| 3 | [Contracts](docs/detectors/03-contracts.md) | `unsafe-primitive`, `untrusted-interface-exercise`, `stale-fetch` |
|
|
98
|
+
| 4 | [Validation](docs/detectors/04-validation.md) | `missing-amount-check`, `partial-function`, `nonconsuming-create`, `unchecked-fetch`, `time-from-argument`, `amount-tolerance`, `divide-before-multiply`, `unconsumed-input`, `hash-concat-collision`, `time-equality`, `missing-ensure`, `ignored-optional` |
|
|
99
|
+
| 5 | [Time](docs/detectors/05-time.md) | `time-dependence`, `weak-randomness` |
|
|
100
|
+
| 6 | [Loops](docs/detectors/06-loops.md) | `ledger-op-in-loop`, `unbounded-input-loop` |
|
|
101
|
+
| 7 | [Hygiene](docs/detectors/07-hygiene.md) | `boolean-cst`, `boolean-equal`, `unused-template-field`, `discarded-update`, `aborting-choice`, `tautological-compare`, `debug-trace`, `rtlo` |
|
|
102
|
+
| 8 | [Upgrade](docs/detectors/08-upgrade.md) | `sdk-version` |
|
|
103
|
+
|
|
104
|
+
<details>
|
|
105
|
+
<summary><b>All detectors</b> with impact and confidence</summary>
|
|
106
|
+
|
|
107
|
+
| Detector | Impact | Confidence | What it finds |
|
|
108
|
+
|---|---|---|---|
|
|
109
|
+
| [`boolean-cst`](docs/detectors/07-hygiene.md#boolean-cst) | Medium | Medium | Boolean constants used as conditions |
|
|
110
|
+
| [`boolean-equal`](docs/detectors/07-hygiene.md#boolean-equal) | Informational | High | Comparison to `True` / `False` |
|
|
111
|
+
| [`controller-from-argument`](docs/detectors/01-authorization.md#controller-from-argument) | High | Medium | Consuming choice controlled only by an unchecked argument party |
|
|
112
|
+
| [`missing-amount-check`](docs/detectors/04-validation.md#missing-amount-check) | Low | Medium | `Decimal` template field not constrained by `ensure` |
|
|
113
|
+
| [`unused-template-field`](docs/detectors/07-hygiene.md#unused-template-field) | Informational | Medium | Template field that no ledger code reads |
|
|
114
|
+
| [`hardcoded-party`](docs/detectors/01-authorization.md#hardcoded-party) | Medium | High | Party identity built from or compared with a text literal |
|
|
115
|
+
| [`partial-function`](docs/detectors/04-validation.md#partial-function) | Low | Medium | Choice argument passed to `head`, `fromSome`, `!!`, ... |
|
|
116
|
+
| [`discarded-update`](docs/detectors/07-hygiene.md#discarded-update) | Medium | High | Ledger actions wrapped in `pure` and never run |
|
|
117
|
+
| [`nonconsuming-create`](docs/detectors/04-validation.md#nonconsuming-create) | High | Medium | Nonconsuming choice creates its own template without archiving `self` |
|
|
118
|
+
| [`unchecked-fetch`](docs/detectors/04-validation.md#unchecked-fetch) | High | Medium | Contract fetched from a choice argument and used without validation |
|
|
119
|
+
| [`time-from-argument`](docs/detectors/04-validation.md#time-from-argument) | Medium | Medium | Deadline logic on a caller-supplied `Time` instead of ledger time |
|
|
120
|
+
| [`amount-tolerance`](docs/detectors/04-validation.md#amount-tolerance) | Medium | High | `Decimal` amounts compared with `abs (a - b) < eps` instead of exactly |
|
|
121
|
+
| [`divide-before-multiply`](docs/detectors/04-validation.md#divide-before-multiply) | Medium | Medium | Result of a division multiplied, compounding its rounding error |
|
|
122
|
+
| [`unconsumed-input`](docs/detectors/04-validation.md#unconsumed-input) | High | Medium | Input contract of the same template read but not archived |
|
|
123
|
+
| [`aborting-choice`](docs/detectors/07-hygiene.md#aborting-choice) | Informational | High | Choice whose body always aborts |
|
|
124
|
+
| [`hash-concat-collision`](docs/detectors/04-validation.md#hash-concat-collision) | Medium | Medium | `sha256` of texts joined without a separator |
|
|
125
|
+
| [`time-equality`](docs/detectors/04-validation.md#time-equality) | Medium | High | Ledger time compared with `==` or `/=` |
|
|
126
|
+
| [`tautological-compare`](docs/detectors/07-hygiene.md#tautological-compare) | Medium | High | Value compared with itself (`payer == payer`) |
|
|
127
|
+
| [`unprotected-archive`](docs/detectors/01-authorization.md#unprotected-archive) | High | Medium | Consuming choice controlled by a non-signatory |
|
|
128
|
+
| [`missing-ensure`](docs/detectors/04-validation.md#missing-ensure) | Medium | High | Template with amount or time fields and no or trivial `ensure` |
|
|
129
|
+
| [`over-disclosure`](docs/detectors/01-authorization.md#over-disclosure) | Medium | Medium | Choice observers taken from the choice argument |
|
|
130
|
+
| [`unsafe-primitive`](docs/detectors/03-contracts.md#unsafe-primitive) | High | High | Unchecked cast of a contract id, interface or `Any` value |
|
|
131
|
+
| [`debug-trace`](docs/detectors/07-hygiene.md#debug-trace) | Informational | High | Debug trace left in production code |
|
|
132
|
+
| [`stuck-asset`](docs/detectors/02-assets.md#stuck-asset) | Medium | Medium | Asset its owner cannot move: no owner-controlled consuming choice |
|
|
133
|
+
| [`sdk-version`](docs/detectors/08-upgrade.md#sdk-version) | Informational | High | DAR built for a Daml-LF 1.x target |
|
|
134
|
+
| [`rtlo`](docs/detectors/07-hygiene.md#rtlo) | High | High | Bidirectional control character (right-to-left override) in source or `Text` |
|
|
135
|
+
| [`delegated-authority-leak`](docs/detectors/01-authorization.md#delegated-authority-leak) | High | Medium | Non-signatory controller passes parties or amounts into a create or exercise |
|
|
136
|
+
| [`untrusted-interface-exercise`](docs/detectors/03-contracts.md#untrusted-interface-exercise) | High | Medium | Interface contract id from the choice argument is exercised or fetched |
|
|
137
|
+
| [`value-to-arbitrary-party`](docs/detectors/02-assets.md#value-to-arbitrary-party) | High | Medium | Asset created for an owner from the choice argument by a non-owner controller |
|
|
138
|
+
| [`time-dependence`](docs/detectors/05-time.md#time-dependence) | Low | Medium | Ledger time decides a branch |
|
|
139
|
+
| [`weak-randomness`](docs/detectors/05-time.md#weak-randomness) | High | Medium | Ledger time or a hash picks a list element or map entry |
|
|
140
|
+
| [`ledger-op-in-loop`](docs/detectors/06-loops.md#ledger-op-in-loop) | Low | Medium | Create, exercise or fetch inside a loop |
|
|
141
|
+
| [`unbounded-input-loop`](docs/detectors/06-loops.md#unbounded-input-loop) | Medium | Medium | Loop over a list from the choice argument with no length check |
|
|
142
|
+
| [`stale-fetch`](docs/detectors/03-contracts.md#stale-fetch) | Medium | Medium | Fetched value used after the contract was replaced by a successor |
|
|
143
|
+
| [`ignored-optional`](docs/detectors/04-validation.md#ignored-optional) | Medium | Medium | `Optional` result discarded or forced with `fromSome` |
|
|
144
|
+
|
|
145
|
+
</details>
|
|
146
|
+
|
|
147
|
+
## Commands
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
damlisk --help # top-level usage and command list
|
|
151
|
+
damlisk --version # installed version
|
|
152
|
+
damlisk list-detectors # every detector with impact and confidence
|
|
153
|
+
damlisk info path/to/project.dar # packages, Daml-LF versions and declarations
|
|
154
|
+
damlisk scan path/to/project.dar # run all detectors on the main package
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
`scan` options:
|
|
158
|
+
|
|
159
|
+
| Option | Meaning |
|
|
160
|
+
|---|---|
|
|
161
|
+
| `--detect a,b` | Run only these detectors |
|
|
162
|
+
| `--exclude a,b` | Skip these detectors |
|
|
163
|
+
| `--json` / `--pretty-json` | Print findings as JSON |
|
|
164
|
+
| `--fail-on <impact>` | Exit with code 1 on a finding of this impact or higher (`high`, `medium`, `low`, `informational`, `none`) |
|
|
165
|
+
| `--traceback` | Show a Python traceback on error |
|
|
166
|
+
|
|
167
|
+
## Examples
|
|
168
|
+
|
|
169
|
+
[`examples/vulnerable/`](examples/vulnerable) has one small Daml project per detector. Each
|
|
170
|
+
holds the cases that are reported and the look-alikes that are not. `examples/dars/` holds the
|
|
171
|
+
Splice DARs used as a real-world baseline in the tests. No DAR is committed: `make dars`
|
|
172
|
+
builds every example with `dpm build` and downloads every published Splice version from the
|
|
173
|
+
official [Splice repository](https://github.com/canton-network/splice/tree/main/daml/dars).
|
|
174
|
+
|
|
175
|
+
## Local development
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
python -m venv .venv
|
|
179
|
+
source .venv/bin/activate
|
|
180
|
+
make dev-init # editable install with the dev dependency group
|
|
181
|
+
make dars # build the example DARs and download the Splice DARs (needs dpm)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Run the tests and linters, and build the wheel:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
make test # pytest
|
|
188
|
+
make lint # mypy, black, flake8, isort
|
|
189
|
+
make build # dist/damlisk-<version>-py3-none-any.whl
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
CI ([`.github/workflows/ci.yml`](.github/workflows/ci.yml)) is started by hand from the Actions
|
|
193
|
+
tab (**Run workflow**). It runs the same steps inside the Nix dev shell from
|
|
194
|
+
[`flake.nix`](flake.nix): it installs dpm and the Daml SDK, runs `make dars`, then lint and
|
|
195
|
+
tests. Run it locally with:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
nix develop --command make ci
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Publishing to PyPI
|
|
202
|
+
|
|
203
|
+
Pushing a `v*.*.*` tag runs [`.github/workflows/workflow.yml`](.github/workflows/workflow.yml).
|
|
204
|
+
It builds the sdist and wheel with the tag as the version (`v0.2.0` gives `damlisk --version`
|
|
205
|
+
= `0.2.0`), checks that, and uploads to PyPI through trusted publishing, so no API token is
|
|
206
|
+
stored in the repository:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
git tag v0.2.0
|
|
210
|
+
git push origin v0.2.0
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
damlisk is licensed under the [Apache License, Version 2.0](LICENSE).
|