-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Sam Washko <[email protected]>
- Loading branch information
1 parent
341582a
commit 2226bc4
Showing
6 changed files
with
167 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,77 @@ | ||
.DEFAULT_GOAL := help | ||
VERSION ?= $(shell dunamai from git --style pep440 --format "{base}.dev{distance}+{commit}") | ||
|
||
install-dev: | ||
.PHONY: env | ||
env: ## Display information about the current environment. | ||
poetry env info | ||
|
||
.PHONY: install-dev | ||
install-dev: ## Install all dependencies including dev and test dependencies, as well as pre-commit. | ||
poetry install --with dev --with test --extras "tensorflow h5py" | ||
pre-commit install | ||
|
||
install: | ||
.PHONY: install | ||
install: ## Install required dependencies. | ||
poetry install | ||
|
||
install-prod: | ||
.PHONY: install-prod | ||
install-prod: ## Install prod dependencies. | ||
poetry install --with prod | ||
|
||
install-test: | ||
.PHONY: install-test | ||
install-test: ## Install test dependencies. | ||
poetry install --with test --extras "tensorflow h5py" | ||
|
||
clean: | ||
pip uninstall modelscan | ||
.PHONY: clean | ||
clean: ## Uninstall modelscan | ||
python -m pip uninstall modelscan | ||
|
||
.PHONY: test | ||
test: ## Run pytests. | ||
poetry run pytest tests/ | ||
|
||
test: | ||
poetry run pytest | ||
.PHONY: test-cov | ||
test-cov: ## Run pytests with code coverage. | ||
poetry run pytest --cov=modelscan --cov-report xml:cov.xml tests/ | ||
|
||
build: | ||
.PHONY: build | ||
build: ## Build the source and wheel achive. | ||
poetry build | ||
|
||
.PHONY: build-prod | ||
build-prod: version | ||
build-prod: ## Update the version and build wheel archive. | ||
poetry build | ||
|
||
version: | ||
.PHONY: version | ||
version: ## Bumps the version of the project. | ||
echo "__version__ = '$(VERSION)'" > modelscan/_version.py | ||
poetry version $(VERSION) | ||
|
||
.PHONY: lint | ||
lint: bandit mypy | ||
lint: ## Run all the linters. | ||
|
||
bandit: | ||
.PHONY: bandit | ||
bandit: ## Run SAST scanning. | ||
poetry run bandit -c pyproject.toml -r . | ||
|
||
mypy: | ||
.PHONY: mypy | ||
mypy: ## Run type checking. | ||
poetry run mypy --ignore-missing-imports --strict --check-untyped-defs . | ||
|
||
format: | ||
.PHONY: black | ||
format: ## Run black to format the code. | ||
black . | ||
|
||
|
||
.PHONY: help | ||
help: ## List all targets and help information. | ||
@grep --no-filename -E '^([a-z.A-Z_%-/]+:.*?)##' $(MAKEFILE_LIST) | sort | \ | ||
awk 'BEGIN {FS = ":.*?(## ?)"}; { \ | ||
if (length($$1) > 0) { \ | ||
printf " \033[36m%-30s\033[0m %s\n", $$1, $$2; \ | ||
} else { \ | ||
printf "%s\n", $$2; \ | ||
} \ | ||
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
# modelscan Severity Levels | ||
|
||
modelscan classifies potentially malicious code injection attacks in the following four severity levels. | ||
modelscan classifies potentially malicious code injection attacks in the following four severity levels. | ||
<br> </br> | ||
|
||
- **CRITICAL:** A model file that consists of unsafe operators/globals that can execute code is classified at critical severity. These operators are: | ||
- exec, eval, runpy, sys, open, breakpoint, os, subprocess, socket, nt, posix | ||
- exec, eval, runpy, sys, open, breakpoint, os, subprocess, socket, nt, posix | ||
<br> </br> | ||
- **HIGH:** A model file that consists of unsafe operators/globals that can not execute code but can still be exploited is classified at high severity. These operators are: | ||
- webbrowser, httplib, request.api, Tensorflow ReadFile, Tensorflow WriteFile | ||
- webbrowser, httplib, request.api, Tensorflow ReadFile, Tensorflow WriteFile | ||
<br> </br> | ||
- **MEDIUM:** A model file that consists of operators/globals that are neither supported by the parent ML library nor are known to modelscan are classified at medium severity. | ||
- Keras Lambda layer can also be used for arbitrary code execution. In general, it is not a best practise to add a Lambda layer to a ML model that can get exploited for code injection attacks. | ||
- Work in Progress: Custom operators will be classified at medium severity. | ||
- **MEDIUM:** A model file that consists of operators/globals that are neither supported by the parent ML library nor are known to modelscan are classified at medium severity. | ||
- Keras Lambda layer can also be used for arbitrary code execution. In general, it is not a best practise to add a Lambda layer to a ML model that can get exploited for code injection attacks. | ||
- Work in Progress: Custom operators will be classified at medium severity. | ||
<br> </br> | ||
- **LOW:** At the moment no operators/globals are classified at low severity level. | ||
- **LOW:** At the moment no operators/globals are classified at low severity level. |
Oops, something went wrong.