Skip to content
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
venv
venv
.DS_Store
17 changes: 12 additions & 5 deletions pre_commit_hooks/vscode.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,26 @@
import hashlib


def filter_findings(findings, configuration):
return list(filter(lambda finding: finding["controlName"] not in configuration, findings))


def main():
cwd = os.getcwd()
cwd_hash = hashlib.md5(cwd.encode('utf-8')).hexdigest()
with open('/tmp/controls/.precommit/' + cwd_hash + '.state.json', 'r') as json_file:
cwd_hash = hashlib.md5(cwd.encode("utf-8")).hexdigest()
with open("/tmp/controls/.precommit/" + cwd_hash + ".state.json", "r") as json_file:
state = json.load(json_file)
findings = state.get("findings", [])
configuration = state.get("configuration", [])
if configuration:
findings = filter_findings(findings, configuration)

findings = state.get('findings', [])
print(f"Found {len(findings)} findings")
if findings:
exit(1)

exit(0)


if __name__ == "__main__":
main()
main()
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = jit_ide_pre_commit_hooks
version = 0.0.1
version = 0.0.2
url = https://github.com/jitsecurity/ide-pre-commit-hooks
license = MIT
license_file = LICENSE
Expand Down