|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "f24e2363", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "[](https://docs.safetycli.com/)" |
| 9 | + ] |
| 10 | + }, |
| 11 | + { |
| 12 | + "cell_type": "markdown", |
| 13 | + "id": "b4f4e8ff", |
| 14 | + "metadata": {}, |
| 15 | + "source": [ |
| 16 | + "# Safety CLI Quickstart Guide\n", |
| 17 | + "\n", |
| 18 | + "## Introduction\n", |
| 19 | + "Safety CLI is a Python dependency vulnerability scanner designed to enhance software supply chain security by detecting packages with known vulnerabilities and malicious packages in local development environments, CI/CD, and production systems. Safety CLI can be deployed in minutes and provides clear, actionable recommendations for remediation of detected vulnerabilities.\n", |
| 20 | + "\n", |
| 21 | + "Leveraging the industry's most comprehensive database of vulnerabilities and malicious packages, Safety CLI Scanner allows teams to detect vulnerabilities at every stage of the software development lifecycle.\n", |
| 22 | + "\n", |
| 23 | + "\n", |
| 24 | + "## Installation\n", |
| 25 | + "To install Safety, run the following command (please ignore the `%%capture` text, this is just to suppress jupyter notebook output):\n" |
| 26 | + ] |
| 27 | + }, |
| 28 | + { |
| 29 | + "cell_type": "code", |
| 30 | + "execution_count": 4, |
| 31 | + "id": "227ab8d1", |
| 32 | + "metadata": {}, |
| 33 | + "outputs": [], |
| 34 | + "source": [ |
| 35 | + "%%capture\n", |
| 36 | + "!pip install safety" |
| 37 | + ] |
| 38 | + }, |
| 39 | + { |
| 40 | + "cell_type": "code", |
| 41 | + "execution_count": 11, |
| 42 | + "id": "8493f5de", |
| 43 | + "metadata": {}, |
| 44 | + "outputs": [ |
| 45 | + { |
| 46 | + "name": "stdout", |
| 47 | + "output_type": "stream", |
| 48 | + "text": [ |
| 49 | + "\u001b[1mSafety\u001b[0m 3.2.5 scanning /safety/docs\n", |
| 50 | + "2024-09-05 21:34:45 UTC\n", |
| 51 | + "\n", |
| 52 | + "\u001b[1;39;49mAccount\u001b[0m: [Your Name], [email protected] \n", |
| 53 | + "\u001b[1;39;49m Git branch\u001b[0m: feature/demo-notebook\n", |
| 54 | + "\u001b[1;39;49m Environment\u001b[0m: Stage.development\n", |
| 55 | + "\u001b[1;39;49m Scan policy\u001b[0m: None, using Safety CLI default policies\n", |
| 56 | + "\n", |
| 57 | + "\u001b[2K\u001b[32m[ ]\u001b[0m Fetching Safety's vulnerability database.....\n", |
| 58 | + "\u001b[1A\u001b[2K\u001b[?25lPython detected. Found 1 Python requirement file\n", |
| 59 | + "\u001b[2K\u001b[32m[ ]\u001b[0m Scanning project directory\n", |
| 60 | + "\u001b[2K\u001b[32m[== ]\u001b[0m Analyzing python files and environments for security findingsy findings\n", |
| 61 | + "\u001b[2KDependency vulnerabilities detected:nd environments for security findings\n", |
| 62 | + "\u001b[2Km[= ]\u001b[0m Analyzing python files and environments for security findings\n", |
| 63 | + "\u001b[2K📝 \u001b[1;39;49mdemo_requirements.txt:\u001b[0menvironments for security findings\n", |
| 64 | + "\u001b[2Km[= ]\u001b[0m Analyzing python files and environments for security findings\n", |
| 65 | + "\u001b[2K \u001b[1;33;49minsecure-\u001b[0m\u001b[1;33;49mpackage\u001b[0m\u001b[1;36;49m==\u001b[0m\u001b[1;36;49m0.1\u001b[0m [1 vulnerability found] \n", |
| 66 | + "\u001b[2K -> Vuln ID \u001b[1;39;49m58758\u001b[0m: \n", |
| 67 | + "\u001b[2K Insecure-package 0.2.0 test vuln. \n", |
| 68 | + "\u001b[2K No known fix for \u001b[1;33;49minsecure-\u001b[0m\u001b[1;33;49mpackage\u001b[0m\u001b[1;36;49m==\u001b[0m\u001b[1;36;49m0.1\u001b[0m to fix \u001b[1;36;49m1\u001b[0m vulnerability \n", |
| 69 | + "\u001b[2K Learn more: \u001b[4;94;49mhttps://data.safetycli.com/p/pypi/insecure-package/eda/?\u001b[0m\u001b[4;94;49mfrom\u001b[0m\u001b[4;94;49m=\u001b[0m\u001b[4;94;49m0\u001b[0m\u001b[4;94;49m.1\u001b[0m \n", |
| 70 | + "\u001b[2K\u001b[32m[= ]\u001b[0m Analyzing python files and environments for security findings\n", |
| 71 | + "\u001b[1A\u001b[2K\n", |
| 72 | + "--------------------------------------------------------------------------------\n", |
| 73 | + "Apply Fixes\n", |
| 74 | + "--------------------------------------------------------------------------------\n", |
| 75 | + "\n", |
| 76 | + "\u001b[32mRun `safety scan --apply-fixes`\u001b[0m to update these packages and fix these \n", |
| 77 | + "vulnerabilities. Documentation, limitations, and configurations for applying \n", |
| 78 | + "automated fixes: \n", |
| 79 | + "\u001b[4;94;49mhttps://docs.safetycli.com/safety-docs/vulnerability-remediation/applying-fixes\u001b[0m\n", |
| 80 | + "\n", |
| 81 | + "Alternatively, use your package manager to update packages to their secure \n", |
| 82 | + "versions. Always check for breaking changes when updating packages.\n", |
| 83 | + "\u001b[1;39;49mTip\u001b[0m: For more detailed output on each vulnerability, add the `--detailed-output`\n", |
| 84 | + "flag to safety scan.\n", |
| 85 | + "\n", |
| 86 | + "--------------------------------------------------------------------------------\n", |
| 87 | + "\n", |
| 88 | + "Tested \u001b[1;36;49m1\u001b[0m dependency for known security issues using default Safety CLI policies\n", |
| 89 | + "\u001b[1;36;49m1\u001b[0m security issue found, \u001b[1;36;49m0\u001b[0m fixes suggested\n", |
| 90 | + "\u001b[?25l\u001b[32m[ ]\u001b[0m Processing report\n", |
| 91 | + "\u001b[1A\u001b[2K\u001b[?25l\n", |
| 92 | + "\u001b[2K\u001b[32m[ ]\u001b[0m Processing report\n", |
| 93 | + "\u001b[1A\u001b[2K" |
| 94 | + ] |
| 95 | + } |
| 96 | + ], |
| 97 | + "source": [ |
| 98 | + "import os\n", |
| 99 | + "\n", |
| 100 | + "# Add demo_requirements.txt file with an insecure package\n", |
| 101 | + "with open(\"demo_requirements.txt\", \"w\") as file:\n", |
| 102 | + " file.write(\"insecure-package==0.1\\n\")\n", |
| 103 | + "\n", |
| 104 | + "# Run the safety scan command directly\n", |
| 105 | + "!safety scan \n", |
| 106 | + "\n", |
| 107 | + "# Clean up by removing the demo_requirements.txt file\n", |
| 108 | + "os.remove(\"demo_requirements.txt\")" |
| 109 | + ] |
| 110 | + }, |
| 111 | + { |
| 112 | + "cell_type": "code", |
| 113 | + "execution_count": null, |
| 114 | + "id": "6b354cb6", |
| 115 | + "metadata": {}, |
| 116 | + "outputs": [], |
| 117 | + "source": [] |
| 118 | + } |
| 119 | + ], |
| 120 | + "metadata": { |
| 121 | + "kernelspec": { |
| 122 | + "display_name": "Python 3 (ipykernel)", |
| 123 | + "language": "python", |
| 124 | + "name": "python3" |
| 125 | + }, |
| 126 | + "language_info": { |
| 127 | + "codemirror_mode": { |
| 128 | + "name": "ipython", |
| 129 | + "version": 3 |
| 130 | + }, |
| 131 | + "file_extension": ".py", |
| 132 | + "mimetype": "text/x-python", |
| 133 | + "name": "python", |
| 134 | + "nbconvert_exporter": "python", |
| 135 | + "pygments_lexer": "ipython3", |
| 136 | + "version": "3.11.2" |
| 137 | + } |
| 138 | + }, |
| 139 | + "nbformat": 4, |
| 140 | + "nbformat_minor": 5 |
| 141 | +} |
0 commit comments