{"id":15048248,"url":"https://github.com/github/code-scanning-javascript-demo","last_synced_at":"2025-09-27T10:32:40.932Z","repository":{"id":38095088,"uuid":"310698846","full_name":"github/code-scanning-javascript-demo","owner":"github","description":"GitHub Code Scanning Javascript Tutorial","archived":false,"fork":false,"pushed_at":"2024-08-05T05:49:42.000Z","size":93,"stargazers_count":53,"open_issues_count":14,"forks_count":581,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-10T20:08:09.170Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/github.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-06T20:26:56.000Z","updated_at":"2025-01-09T19:58:45.000Z","dependencies_parsed_at":"2024-12-13T16:09:10.860Z","dependency_job_id":"35489ea3-3281-4ad8-bb2e-33050baaeed3","html_url":"https://github.com/github/code-scanning-javascript-demo","commit_stats":{"total_commits":133,"total_committers":23,"mean_commits":5.782608695652174,"dds":"0.24812030075187974","last_synced_commit":"b7bf53fda9fb7a692cc3276553c84ff4201e16e9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fcode-scanning-javascript-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fcode-scanning-javascript-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fcode-scanning-javascript-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fcode-scanning-javascript-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/github","download_url":"https://codeload.github.com/github/code-scanning-javascript-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234429256,"owners_count":18831240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T21:09:49.053Z","updated_at":"2025-09-27T10:32:35.692Z","avatar_url":"https://github.com/github.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Code Scanning JavaScript Tutorial\n\nWelcome to the Code Scanning JavaScript Tutorial! This tutorial will take you through how to set up GitHub Advanced Security: Code Scanning as well as interpret results that it may find. The following repository contains vulnerability [CVE-2018-20835](https://github.com/advisories/GHSA-x2mc-8fgj-3wmr) (aka Zip Slip).\n\n## Introduction\n\nCode scanning is a feature that you use to analyze the code in a GitHub repository to find security vulnerabilities and coding errors. Any problems identified by the analysis are shown in GitHub.\n\nYou can use code scanning with CodeQL, a semantic code analysis engine. CodeQL treats code as data, allowing you to find potential vulnerabilities in your code with greater confidence than traditional static analyzers.\n\nThis tutorial with use CodeQL Analysis with Code Scanning in order to search for vulnerabilities within your code. \n\n## Instructions\n\n\u003cdetails\u003e\n\u003csummary\u003eFork this repo\u003c/summary\u003e\n\u003cp\u003e \n  \nBegin by [forking this repo](https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/fork-a-repo).\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eEnable Code Scanning\u003c/summary\u003e\n\u003cp\u003e \n\n#### Security tab\n\nClick on the `Security` tab.\n\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6920330/96745784-81480380-1394-11eb-886d-55e7c207c9c9.png\" width=\"70%\"/\u003e\n\n#### Set up code scanning\n\nClick `Set up code scanning`.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6920330/96745792-8311c700-1394-11eb-83fd-e47d09bf148e.png\" width=\"70%\"/\u003e\n\n#### Setup Workflow\n\nClick the `Setup this workflow` button by CodeQL Analysis.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6920330/96746928-aee17c80-1395-11eb-9eb2-657dd0e92ed9.png\" width=\"70%\"/\u003e\n\nThis will create a GitHub Actions Workflow file with CodeQL already set up. Since JavaScript is an interpreted language there is no need to configure any builds. See the [documentation](https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/running-codeql-code-scanning-in-your-ci-system) if you would like to configure CodeQL Analysis with a 3rd party CI system instead of using GitHub Actions.\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \n\u003csummary\u003eActions Workflow file\u003c/summary\u003e\n\u003cp\u003e\n\n#### Actions Workflow\n\nThe Actions Workflow file contains a number of different sections including:\n1. Checking out the repository\n2. Initializing the CodeQL Action\n3. Running Autobuilder (not necessary for interpreted languages)\n4. Running the CodeQL Analysis\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6920330/96746940-b143d680-1395-11eb-9778-0891525a39c1.png\" width=\"80%\"/\u003e\n\nClick `Start Commit` -\u003e `Commit this file` to commit the changes.\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eGitHub Actions Progress\u003c/summary\u003e\n\n\u003cp\u003e\n \n#### GitHub Actions Progress\n\nClick `Actions` tab -\u003e `CodeQL`\n\nClick the specific workflow run. You can view the progress of the Workflow run until the analysis completes.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6920330/96748337-64f99600-1397-11eb-9ab7-b78ec23466ae.png\" width=\"80%\"/\u003e\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eSecurity Issues\u003c/summary\u003e\n\u003cp\u003e\n  \nOnce the Workflow has completed, click the `Security` tab -\u003e ` Code Scanning Alerts`. An security alert \"Arbitrary file write during zip extraction (\"Zip Slip\")\n\" should be visible.\n\n#### Security Alert View\n\nClicking on the security alert will provide details about the security alert including:\nA description of the issue\nA tag to the CWE that it is connected to as well as the type of alert (Error, Warning, Note)\nThe line of code that triggered the security alert\nThe ability to dismiss the alert depending on certain conditions (false positive? won't fix? used in tests?)\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6920330/96749627-0c2afd00-1399-11eb-92f9-3356e387201f.png\" width=\"80%\"/\u003e\n\n#### Security Alert Description\n\nClick `Show more` to view a full desciption of the alert including examples and links to additional information.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6920330/96749626-0c2afd00-1399-11eb-9ef5-9560ca585a1b.png\" width=\"80%\"/\u003e\n\n#### Security Full Description\n\n\u003cimg width=\"80%\" src=\"https://user-images.githubusercontent.com/6920330/97208478-8bea0a80-1791-11eb-8a2a-f625649312f0.png\"\u003e\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eShow Paths\u003c/summary\u003e\n\u003cp\u003e\n\n#### Show Paths Button\n\nCodeQL Analysis is able to trace the dataflow path from source to sink and gives you the ability to view the path traversal within the alert.\n\nClick `show paths` in order to see the dataflow path that resulted in this alert.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6920330/96749839-514f2f00-1399-11eb-80f7-1b83e5c195e7.png\" width=\"80%\"/\u003e\n\n#### Show Paths View\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6920330/96749909-6926b300-1399-11eb-99df-143d17804aeb.png\" width=\"80%\"/\u003e\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003cp\u003e  \n  \n\u003csummary\u003eFix the Security Alert\u003c/summary\u003e\n\nIn order to fix this specific alert, we will need to ensure that the destination file paths is the only location where files can be written to.\n\nClick on the `Code` tab and [Edit](https://docs.github.com/en/free-pro-team@latest/github/managing-files-in-a-repository/editing-files-in-your-repository) the `index.js` file. Navigate to Line 264 of the `index.js` file and modify the line:\n\n`var srcpath = path.resolve(cwd, header.linkname)`\n\nto\n\n`var srcpath = path.join(cwd, path.join('/', header.linkname))`\n\nClick `Create a new branch for this commit and start a pull request`, name the branch `fix-zip-slip`, and create the Pull Request.\n\n#### Pull Request Status Check\n\nIn the Pull Request, you will notice that the CodeQL Analysis has started as a status check. Wait until it completes.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6920330/96752215-2adec300-139c-11eb-9c5e-3a04f24ba0bf.png\" width=\"80%\"/\u003e\n\n#### Security Alert Details\n\nAfter the Workflow has completed click on `Details` by the `Code Scanning Results / CodeQL` status check. \n\n\u003cimg src=\"https://user-images.githubusercontent.com/6920330/96752487-85781f00-139c-11eb-943d-602f2de98998.png\" width=\"80%\"/\u003e\n\n#### Fixed Alert\n\nNotice that Code Scanning has detected that this Pull Request will fix the Zip Slip vulnerability that was detected before.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6920330/96752486-85781f00-139c-11eb-9a7e-3ccbc81da3d1.png\" width=\"80%\"/\u003e\n\nMerge the Pull Request. After the Pull Request has been merged, another Workflow will kick off to scan the repository for any vulnerabilties. \n\n#### Closed Security Alerts\n\nAfter the final Workflow has completed, navigate back to the `Security` tab and click `Closed`. Notice that the Zip Slip security alert now shows up as a closed issue.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6920330/96753441-e0f6dc80-139d-11eb-9a2a-d53075b6331e.png\" width=\"80%\"/\u003e\n\n#### Traceability\n\nClick on the security alert and notice that it details when the fix was made, by whom, and the specific commit. This provides full traceability to detail when and how a security alert was fixed and exactly what was changed to remediate the issue.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/6920330/96753440-e05e4600-139d-11eb-81ed-c22e4f41d74a.png\" width=\"80%\"/\u003e\n\n\u003c/p\u003e\n\u003c/details\u003e\n  \n## Next Steps\n\nReady to talk about advanced security features for GitHub Enterprise? [Contact Sales](https://enterprise.github.com/contact) for more information!\n\nCheck out [GitHub's Security feature page](https://github.com/features/security) for more security features embedded into GitHub.\n\nCheck out the Code Scanning [documentation](https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/about-code-scanning) for additional configuration options and technical details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Fcode-scanning-javascript-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgithub%2Fcode-scanning-javascript-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Fcode-scanning-javascript-demo/lists"}