An automated pre-commit hook which prompts and prevents developers from including vulnerable third-party dependencies in their application.
- The current script query from http://paws-backend.ap-southeast-2.elasticbeanstalk.com/threat/search. This maybe taken down hence please change line 18 in
pre-commit.pyfromasync with session.post('http://paws-backend.ap-southeast-2.elasticbeanstalk.com/threat/search',json={"package_manager_type" : "npm","package_list" : [package],"level": 0, "severity": ["CRITICAL"], "date": "None"}) as r:to
async with session.post('http://127.0.0.1:5000/threat/search',json={"package_manager_type" : "npm","package_list" : [package],"level": 0, "severity": ["CRITICAL"], "date": "None"}) as r:
and ensure the backend located at https://github.com/UNSW-pAWS/webapp-backend is up and running before proceeding.
- If the api have not been changed please proceed to the section Original proceedures.
- If the api have been changed please proceeed to the section Change proceedures.
- head to root of your folder type
npm init
and fill in the information
- type
git init
to initialise a git repo
- head to package.json and enter the following into scripts (assuming all the developers are using linux)
"preinstall": "git clone https://github.com/UNSW-pAWS/pre-commit-hook.git && chmod +x ./pre-commit-hook/setup.sh && bash ./pre-commit-hook/setup.sh"
-
git clone your project repo
-
run
npm i
(preinstall script will run and setup your pre-commit hook on developer's local enviroment)
The original package is able to work as it use pyinstaller to make pre-commit.py into an executable with all the dependency needed. As the change version of the file had not been compiled by pyinstaller we will have to give it a virtual enviroment to work within. Therefore, the following steps need to be undertaken.
python3 -m venv [environment-name]source [environment-name]/bin/activatepip install -r requirements.txtgit initif you did not have a git repocp pre-commit.py .git/hooks/pre-commitchmod +x .git/hooks/pre-commit
Now you could create your package.json and test our product :)
