2022-07-18 16:21:45 +00:00
|
|
|
{ lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, callPackage
|
|
|
|
, semgrep-core
|
|
|
|
, buildPythonApplication
|
|
|
|
, pythonPackages
|
2022-09-22 12:36:57 +00:00
|
|
|
, pythonRelaxDepsHook
|
2022-07-18 16:21:45 +00:00
|
|
|
|
|
|
|
, pytestCheckHook
|
|
|
|
, git
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
common = callPackage ./common.nix { };
|
|
|
|
in
|
|
|
|
buildPythonApplication rec {
|
|
|
|
pname = "semgrep";
|
|
|
|
inherit (common) version;
|
|
|
|
src = "${common.src}/cli";
|
|
|
|
|
|
|
|
SEMGREP_CORE_BIN = "${semgrep-core}/bin/semgrep-core";
|
|
|
|
|
2022-09-22 12:36:57 +00:00
|
|
|
nativeBuildInputs = [ pythonRelaxDepsHook ];
|
|
|
|
pythonRelaxDeps = [
|
|
|
|
"attrs"
|
|
|
|
"boltons"
|
|
|
|
"jsonschema"
|
|
|
|
"typing-extensions"
|
|
|
|
];
|
2022-07-18 16:21:45 +00:00
|
|
|
|
2022-09-22 12:36:57 +00:00
|
|
|
postPatch = ''
|
2022-07-18 16:21:45 +00:00
|
|
|
# remove git submodule placeholders
|
|
|
|
rm -r ./src/semgrep/{lang,semgrep_interfaces}
|
|
|
|
# link submodule dependencies
|
|
|
|
ln -s ${common.langsSrc}/ ./src/semgrep/lang
|
|
|
|
ln -s ${common.interfacesSrc}/ ./src/semgrep/semgrep_interfaces
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkInputs = [ git pytestCheckHook ] ++ (with pythonPackages; [
|
|
|
|
pytest-snapshot
|
|
|
|
pytest-mock
|
|
|
|
pytest-freezegun
|
|
|
|
types-freezegun
|
|
|
|
]);
|
|
|
|
disabledTests = [
|
|
|
|
# requires networking
|
|
|
|
"tests/unit/test_metric_manager.py"
|
|
|
|
];
|
|
|
|
preCheck = ''
|
|
|
|
# tests need a home directory
|
|
|
|
export HOME="$(mktemp -d)"
|
|
|
|
|
|
|
|
# disabledTestPaths doesn't manage to avoid the e2e tests
|
|
|
|
# remove them from pyproject.toml
|
|
|
|
# and remove need for pytest-split
|
|
|
|
substituteInPlace pyproject.toml \
|
|
|
|
--replace '"tests/e2e",' "" \
|
|
|
|
--replace 'addopts = "--splitting-algorithm=least_duration"' ""
|
|
|
|
'';
|
|
|
|
|
|
|
|
propagatedBuildInputs = with pythonPackages; [
|
|
|
|
attrs
|
|
|
|
boltons
|
|
|
|
colorama
|
|
|
|
click
|
|
|
|
click-option-group
|
|
|
|
glom
|
|
|
|
requests
|
|
|
|
ruamel-yaml
|
|
|
|
tqdm
|
|
|
|
packaging
|
|
|
|
jsonschema
|
|
|
|
wcmatch
|
|
|
|
peewee
|
|
|
|
defusedxml
|
|
|
|
urllib3
|
|
|
|
typing-extensions
|
|
|
|
python-lsp-jsonrpc
|
|
|
|
];
|
|
|
|
|
|
|
|
meta = common.meta // {
|
|
|
|
description = common.meta.description + " - cli";
|
|
|
|
};
|
|
|
|
}
|