10000 GitHub - codercyou/vscode-codeql-starter at experimental/atm
[go: up one dir, main page]

Skip to content

codercyou/vscode-codeql-starter

 
 

Repository files navigation

vscode-codeql-starter for Adaptive Threat Modeling

You can set up this workspace in Visual Studio Code to get started with adaptive threat modeling.

Note: Adaptive threat modeling is in beta and subject to change. It is currently only available for JavaScript and TypeScript code.

Prerequisites

  1. Adaptive threat modeling requires a machine with a CPU with AVX (Advanced Vector Extensions). If you are not sure whether your CPU has AVX, check this list.

  2. If you are running Windows, you may need to install the Microsoft Visual C++ 2019 Redistributable.

    1. Go to the Visual Studio downloads.
    2. From the "All Downloads" section, select Other Tools and Frameworks.
    3. Select your CPU architecture (x64, ARM64, or x86), then press Download.
    4. Launch the installer and follow the steps as prompted.

    We found that this was not necessary for Windows 10 Pro during internal testing, however we have not tested other versions of Windows.

  3. Install Visual Studio Code (VS Code).

  4. Install the CodeQL extension for Visual Studio Code. Make sure that you have at least version 1.0.5 installed.

Installing the CodeQL CLI for adaptive threat modeling

  1. Install the adaptive threat modeling beta CodeQL CLI.

    • Download the codeql-all.zip file that you have been provided with. The link to download this file is included in the "Getting started" document pinned to the #codeql-atm-beta channel on the GitHub Security Lab Slack instance.
    • If you use macOS Catalina, run xattr -c codeql-all.zip before extracting the zip file. For more information on installing on macOS Catalina, see "Getting started with the CodeQL CLI."
    • Create a new directory named codeql-cli-atm-home where you can place the adaptive threat modeling beta CodeQL CLI. For example, $HOME/codeql-cli-atm-home
    • Extract codeql-all.zip into the codeql-cli-atm-home subdirectory you just created.
  2. Check that the codeql-cli-atm-home directory has the following structure:

    codeql-cli-atm-home
    └── codeql
        ├── LICENSE.md
        ├── Open-Source-Notices
        ├── codeql
        ├── codeql.cmd
        ├── codeql.exe
        ├── cpp
        ├── csharp
        ├── go
        ├── java
        ├── javascript
        ├── legacy-upgrades
        ├── lib-extra
        ├── ml-models
        ├── python
        └── tools
    
  3. Set the CodeQL CLI path setting in VS Code to the following path using the Settings Editor:

    • For Windows, use path/to/codeql-cli-atm-home/codeql/codeql.exe
    • For other operating systems, use path/to/codeql-cli-atm-home/codeql/codeql

Running a boosted security query in Visual Studio Code

  1. Clone this repository to your computer and check out the experimental/atm branch. You can do this from a terminal by running git clone --branch experimental/atm https://github.com/github/vscode-codeql-starter.git.

  2. Download the submodules by running git submodule update --init --remote from a terminal with a current working directory of the cloned repository.

  3. In VS Code, click File > Open Workspace. Select the file vscode-codeql-starter.code-workspace in your checkout of this repository.

  4. You will see several folders open in the left sidebar:

    • The ql folder contains the open source CodeQL standard library for JavaScript. It tracks the experimental/atm branch of the CodeQL repository. This folder contains the boosted query for NoSQL injection, which is located at ql/javascript/ql/src/experimental/adaptivethreatmodeling/NosqlInjectionATM.ql. You can also run the standard queries from here, and browse the libraries.
    • The codeql-custom-queries-javascript folder is ready for you to start developing your own custom queries for JavaScript, while using the standard libraries. There is an example query, example.ql, to get you started.
  5. Open the boosted NoSQL injection query N 799F osqlInjectionATM.ql in VS Code. This is located at ql/javascript/ql/src/experimental/adaptivethreatmodeling/NosqlInjectionATM.ql.

  6. Select a database to run the query against using CodeQL for VS Code. An example database that demonstrates some of the potential vulnerabilities ATM can identify is provided in "Creating a boosted security query." For more information, see "Choosing a database" in the CodeQL for VS Code help.

  7. Run the boosted query using CodeQL for VS Code. For more information, see "Running a query" in the CodeQL for VS Code help.

  8. Each result of the boosted query is scored, with higher scores more likely to be true positive results.

  9. Sort the results of the boosted query such that the results with the highest scores appear first by pressing the "Message" table header until a downwards arrow appears like so:

    Sort the boosted query results by making sure the #alerts predicate is selected then pressing the "Message" table header until a downwards arrow appears

Creating your own boosted security queries

For information about writing new boosted queries, see the following:

Updating the libraries for adaptive threat modeling

From time to time, we may release updates to the adaptive threat modeling libraries and queries. To keep these up to date, run git submodule update --remote regularly.

Support and feedback

We want to help you get the most from ATM, and also hear your feedback. For more information, see "Support and feedback."

Contributing

This project welcomes contributions. For more information, see CONTRIBUTING.md.

License

This project is licensed under the MIT License.

The CodeQL extension for Visual Studio Code is licensed under the MIT License. The version of CodeQL used by the CodeQL extension is subject to the GitHub CodeQL Terms & Conditions.

About

Starter workspace to use with the CodeQL extension for Visual Studio Code.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • CodeQL 100.0%
0