Coder Social home page Coder Social logo

obetomuniz / ai-security-check-for-pull-requests-action Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 1.0 104 KB

A GitHub Action that uses OpenAI's GPT to identify security and privacy vulnerabilities and comment to the pull requests

Home Page: https://github.com/marketplace/actions/ai-security-check-for-pull-request

License: Other

JavaScript 100.00%

ai-security-check-for-pull-requests-action's Introduction

AI Security Check for Pull Requests

This GitHub Action uses OpenAI's GPT to analyze code in pull requests and identify potential security and privacy vulnerabilities and comment to the pull request with the findings.

Configuration

To configure this action in your repository, you should set up the following secrets:

GH_TOKEN

Setup this secret with a GitHub Personal Access Token with the repo and write:discussion scopes enabled. This token is used to fetch pull request details and add comments to the pull request.

OPENAI_TOKEN

Setup this secret with your OpenAI API Key, which is required to make API calls to OpenAI's GPT.

Workflow File (e.g. ./github/workflows/ai-security-check-for-pr.yml)

Create a new workflow file in your repository and paste the following content:

name: AI Security Check for Pull Requests

on:
  pull_request:
    branches:
      - main

jobs:
  ai_security_check_for_pull_requests:
    runs-on: ubuntu-latest

    steps:
      - name: Check out repository
        uses: actions/checkout@v2

      - name: Set up Node.js
        uses: actions/setup-node@v2
        with:
          node-version: 16

      - name: Install dependencies
        run: npm ci

      - name: Finding security and privacy code vulnerabilities
        id: ai_security_check
        uses: obetomuniz/[email protected]
        env:
          GH_TOKEN: ${{ secrets.GH_TOKEN }}
          GH_REPOSITORY: ${{ github.repository }}
          GH_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.number }}
          OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }}

      - name: Comment on pull request
        uses: actions/github-script@v6
        env:
          PR_COMMENT: ${{ steps.ai_security_check.outputs.pr_comment }}
        with:
          github-token: ${{ secrets.GH_TOKEN }}
          script: |
            const prComment = process.env.PR_COMMENT || "No security or privacy issues found.";
            const { data } = await github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: prComment
            });

Replace main with your default branch if necessary.

Usage

Once the action is configured, it will automatically run and analyze the code in each pull request targeting the specified branch(es). If it finds any security or privacy issues, it will add a comment to the pull request with the findings. Otherwise, it will comment that no issues were found.

ai-security-check-for-pull-requests-action's People

Contributors

obetomuniz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.