Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snyk fix ca2753884b7af29829d75b5bbfd54b4a #1416

Open
wants to merge 135 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
bc90820
Create Jenkinsfile
Robthreefold Jul 30, 2020
e921a68
Update Jenkinsfile
Robthreefold Jul 30, 2020
9ec8e3e
Update Jenkinsfile
Robthreefold Jul 30, 2020
52c4858
Build Node app
Robthreefold Sep 9, 2021
112c9a3
Update azure-pipelines.yml for Azure Pipelines
Robthreefold Sep 9, 2021
1ab1136
Update azure-pipelines.yml for Azure Pipelines
Robthreefold Sep 9, 2021
530d667
modified: Jenkinsfile
Robthreefold Jan 13, 2022
2a96bb3
modified: Jenkinsfile
Robthreefold Jan 13, 2022
9c099e9
modified: Jenkinsfile
Robthreefold Jan 13, 2022
b0fff9e
modified: Jenkinsfile
Robthreefold Jan 13, 2022
70f5881
modified: Jenkinsfile
Robthreefold Jan 13, 2022
ac4dce2
modified: Jenkinsfile
Robthreefold Jan 13, 2022
2818595
modified: Jenkinsfile
Robthreefold Jan 13, 2022
5765d24
modified: Jenkinsfile
Robthreefold Jan 13, 2022
0a40bdf
Push GitHub action to make GitHub issues
Robthreefold Mar 9, 2022
04b7a93
Modify GitHub actions
Robthreefold Mar 9, 2022
9d345f6
Modify GitHub actions
Robthreefold Mar 9, 2022
f370e74
Modify GitHub actions repo
Robthreefold Mar 9, 2022
a660e7f
Modify GitHub actions repo
Robthreefold Mar 9, 2022
c399ddd
Modify GitHub action
Robthreefold Mar 9, 2022
d075d01
Modify GitHub action
Robthreefold Mar 9, 2022
4b1864d
Modify GitHub action
Robthreefold Mar 9, 2022
5f16e0c
Modify GitHub action
Robthreefold Mar 9, 2022
fdf805f
Modify GitHub action
Robthreefold Mar 9, 2022
1642c24
Modify GitHub action
Robthreefold Mar 9, 2022
4bc3f1f
modified: package-lock.json
Robthreefold May 3, 2022
10702e0
modified: .gitignore
Robthreefold May 3, 2022
4d5538a
fix: package.json & package-lock.json to reduce vulnerabilities
snyk-bot May 3, 2022
92e504a
Merge pull request #147 from rhicksiii91/snyk-fix-32b919332ea35a00386…
Robthreefold May 3, 2022
81ac4b8
fix: package.json & package-lock.json to reduce vulnerabilities
snyk-bot May 3, 2022
7b46afe
Merge pull request #148 from rhicksiii91/snyk-fix-fffda9ea97e0e82bafe…
Robthreefold May 3, 2022
37c338c
fix: package.json & package-lock.json to reduce vulnerabilities
snyk-bot May 3, 2022
67168f6
Merge pull request #161 from rhicksiii91/snyk-fix-e75510891d97d3473a7…
Robthreefold May 3, 2022
9ba0945
Update run_snyk_gh_issues.yml
Robthreefold May 11, 2022
400ed16
Create python-app.yml
Robthreefold May 11, 2022
241645c
Update python-app.yml
Robthreefold May 11, 2022
3f2326a
new file: ci-scripts-library
Robthreefold May 11, 2022
e14a50c
Merge branch 'master' of https://github.com/rhicksiii91/goof
Robthreefold May 11, 2022
85186a6
deleted: ci-scripts-library
Robthreefold May 11, 2022
6a5b77b
new file: ci-scripts-library/.github/workflows/build-test-release.yml
Robthreefold May 11, 2022
1b117c6
Update python-app.yml
Robthreefold May 11, 2022
6a2d884
Update python-app.yml
Robthreefold May 11, 2022
8a6269b
Update python-app.yml
Robthreefold May 11, 2022
bbac1ef
Create snyktogithubissue.yml
Robthreefold May 11, 2022
e3a88cf
Delete snyktogithubissue.yml
Robthreefold May 11, 2022
d1543e0
Create snyk-scm-issues-to-gh-issues.yml
Robthreefold May 11, 2022
dd51db8
modified: Jenkinsfile
Robthreefold May 17, 2022
6296de4
Merge branch 'master' of https://github.com/rhicksiii91/goof
Robthreefold May 17, 2022
f91a9af
modified: package.json
Robthreefold Jun 15, 2022
226f962
does snyk-to-html-work
Robthreefold Jun 28, 2022
e989e65
Rename .github/snowflakestuff.yml to .github/workflows/snowflakestuff…
Robthreefold Jun 28, 2022
96c63ab
Update snowflakestuff.yml
Robthreefold Jun 28, 2022
c4bc315
Update snowflakestuff.yml
Robthreefold Jun 28, 2022
9b6f7f2
Update snowflakestuff.yml
Robthreefold Jun 28, 2022
6396fe7
Update snowflakestuff.yml
Robthreefold Jun 28, 2022
3a0fe80
Update snyk-scm-issues-to-gh-issues.yml
Robthreefold Aug 1, 2022
7313958
Update snyk-scm-issues-to-gh-issues.yml
Robthreefold Aug 1, 2022
9866888
Update snyk-scm-issues-to-gh-issues.yml
Robthreefold Aug 1, 2022
a2566dc
Update snyk-scm-issues-to-gh-issues.yml
Robthreefold Aug 1, 2022
3725699
Update snyk-scm-issues-to-gh-issues.yml
Robthreefold Aug 1, 2022
9f82faf
remove requirement.txt
Robthreefold Jan 27, 2023
5b07fa5
Updating ci-scripts-library
Robthreefold Feb 2, 2023
305546c
Updating package.json
Robthreefold Feb 2, 2023
7b81ae1
modified: .github/workflows/python-app.yml
Robthreefold Feb 2, 2023
6ad4f4e
modified: .github/workflows/python-app.yml
Robthreefold Feb 2, 2023
b5a2497
Update ci-scripts
Robthreefold Feb 3, 2023
1daaa92
Update ci-scripts
Robthreefold Feb 3, 2023
59ebc10
Update python-app.yml
Robthreefold Feb 3, 2023
ef7f637
Update ci-scripts
Robthreefold Feb 3, 2023
6aaa648
Update ci-scripts
Robthreefold Feb 3, 2023
14c528a
Update ci-scripts
Robthreefold Feb 3, 2023
82f8eac
Update ci-scripts
Robthreefold Feb 3, 2023
0a7058b
Updating GH action
Robthreefold Feb 3, 2023
731c73d
Updating GH action
Robthreefold Feb 3, 2023
9e9c51f
Updating GH action
Robthreefold Feb 3, 2023
4595080
Updating GH action
Robthreefold Feb 3, 2023
2600b54
Updating GH action
Robthreefold Feb 3, 2023
ba02c06
Updating GH action
Robthreefold Feb 3, 2023
884a44e
Updating GH action
Robthreefold Feb 3, 2023
0f995ce
Updating GH action
Robthreefold Feb 3, 2023
7daf023
Updating GH action
Robthreefold Feb 3, 2023
bb712dd
Updating GH action
Robthreefold Feb 3, 2023
4bc377f
Updating GH action
Robthreefold Feb 3, 2023
1b3928c
Updating GH action
Robthreefold Feb 3, 2023
0f52f89
Updating GH action
Robthreefold Feb 3, 2023
761e613
Updating GH action
Robthreefold Feb 3, 2023
f7c73bf
Updating GH action
Robthreefold Feb 3, 2023
ed38cb9
Updating GH action
Robthreefold Feb 3, 2023
2dafe51
Updating GH action
Robthreefold Feb 3, 2023
ef02c5d
Updating GH action
Robthreefold Feb 3, 2023
269f4af
Updating GH action
Robthreefold Feb 3, 2023
cfe11f2
Updating GH action
Robthreefold Feb 3, 2023
e0799ad
Updating GH action
Robthreefold Feb 3, 2023
0907e97
Updating GH action
Robthreefold Feb 3, 2023
8b31146
Updating GH action
Robthreefold Feb 3, 2023
25066ed
Updating GH action
Robthreefold Feb 3, 2023
c6674e4
Updating GH action
Robthreefold Feb 3, 2023
bce14c9
Updating GitHub actions
Robthreefold Feb 9, 2023
cb3fc63
Updating GitHub actions
Robthreefold Feb 9, 2023
82d9fb8
Updating GitHub actions
Robthreefold Feb 9, 2023
b35e916
Updating GitHub actions
Robthreefold Feb 9, 2023
fbb505f
Updating GitHub actions
Robthreefold Feb 9, 2023
222044a
Updating GitHub actions
Robthreefold Feb 9, 2023
e25e982
Updating GitHub actions for env
Robthreefold Feb 9, 2023
fa45d76
Updating GitHub actions for env
Robthreefold Feb 9, 2023
3d5ec57
Updating GitHub actions for env
Robthreefold Feb 9, 2023
43e0a32
Updating GitHub actions for env
Robthreefold Feb 9, 2023
fc3eda9
Updating GitHub actions for env
Robthreefold Feb 9, 2023
23842b1
Updating GitHub actions for env
Robthreefold Feb 10, 2023
74bbe90
Updating GitHub actions for env
Robthreefold Feb 10, 2023
cbbc5af
Updating GitHub actions for env
Robthreefold Feb 10, 2023
c8c8d09
Updating GitHub actions for env
Robthreefold Feb 10, 2023
1b0ed59
Updating GitHub actions for env
Robthreefold Feb 10, 2023
f2e318f
Updating GitHub actions for env
Robthreefold Feb 10, 2023
0983964
Updating GitHub actions for env
Robthreefold Feb 10, 2023
be6de79
Updating GitHub actions for env
Robthreefold Feb 10, 2023
a064e7c
Updating GitHub actions for env
Robthreefold Feb 10, 2023
ca7d0fd
Updating GitHub actions for env
Robthreefold Feb 10, 2023
78d3894
Updating GitHub actions for env
Robthreefold Feb 10, 2023
d0e7ce5
Updating GitHub actions for env
Robthreefold Feb 10, 2023
7cc77db
Updating GitHub actions for env
Robthreefold Feb 10, 2023
f915973
Updating GitHub actions for env
Robthreefold Feb 10, 2023
4cd0c0f
Updating GitHub actions for env
Robthreefold Feb 10, 2023
68da5c8
Updating GitHub actions for env
Robthreefold Feb 10, 2023
4caa0ec
Updating GitHub actions for env
Robthreefold Feb 10, 2023
507d3be
Updating GitHub actions for env
Robthreefold Feb 10, 2023
46eb3f1
Updating GitHub actions for env
Robthreefold Feb 10, 2023
6ad8957
Updating GitHub actions for env
Robthreefold Feb 10, 2023
d5118d5
Updating GitHub actions for env
Robthreefold Feb 10, 2023
edf7245
Set up CI with Azure Pipelines
Robthreefold Nov 14, 2023
5ee5e5c
Set up CI with Azure Pipelines
Robthreefold Mar 15, 2024
1ffe8ce
Delete azure-pipelines-2.yml
Robthreefold Mar 15, 2024
66a02f0
Delete azure-pipelines-1.yml
Robthreefold Mar 15, 2024
efa7dbb
Updating Mongoose
Robthreefold Jun 4, 2024
ed9fe22
fix: package.json & package-lock.json to reduce vulnerabilities
snyk-bot Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
37 changes: 37 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on: [workflow_dispatch]

permissions:
contents: read

env:
REMOTE_REPO_URL: ${{ github.repository }},
GITHUB_ORG: ${{ github.repository.owner }}
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }},
POETRY_VIRTUALENVS_CREATE: false

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: Install Poetry
run: |
pip install -U pip
pip install poetry
poetry install

- name: Install dependencies
run: poetry install --no-interaction --no-root
- name: Create and delete GitHub issues based off of Snyk projects
run: python ci_scripts_library/snyk_scm_issues_to_gh_issues/cli.py snyk-license-check
25 changes: 25 additions & 0 deletions .github/workflows/run_snyk_gh_issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Running Snyk GH Issues

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements2.txt ]; then pip install -r requirements2.txt; fi
- name: Run Snyk_GH_Issues.py
run: python3 Snyk_GH_Issues.py
29 changes: 29 additions & 0 deletions .github/workflows/snowflakestuff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Example workflow using Snyk
on: push
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/node@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --json-file-output=snyk.json


- name: install snyk-to-html
run: |
npm install snyk-to-html -g
cat snyk.json | snyk-to-html -o result.html
mkdir downloads
pwd
ls -al
cp -v /home/runner/work/rhicksiii91/goof/*.html /home/runner/work/rhicksiii91/goof/downloads
- name: Run Snyk test
uses: actions/upload-artifact@v2
with:
name: results
path: downloads
15 changes: 15 additions & 0 deletions .github/workflows/snyk-scm-issues-to-gh-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Snyk SCM Issues to Github Issues
on: workflow_dispatch
# - push
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: snyk-labs/actions/scm-issues-to-gh-issues@main
with:
snyk_prefix: "cse"
use_fresh_issues: "true"
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
REMOTE_REPO_URL: ${{ github.repositoryUrl }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ node_modules
sass
config.rb
npm-debug.log

goofenv
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/goof2.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/libraries/zip_slip.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
pipeline {
agent any
tools
{
nodejs 'NodeJS 18.1.0'
}

environment {
SNYK_TOKEN = 'da12766a-46b6-4186-8ba1-83eb1aae653c'
}

stages {
stage('Install Snyk and Snyk Filter') {
steps {
sh 'node -v'
sh 'npm prune'
sh 'npm install -g snyk'
sh 'npm install -g snyk-filter'
}
}

stage('Build') {
steps {
sh 'node -v'
sh 'npm install'
}
}


stage('Snyk Monitor') {
steps {
sh 'echo "***RUNNING SNYK TEST***"'
sh 'snyk monitor --org=fdf3b63a-9a4e-43d8-bae3-85212f002bea --project-name=JenkinsGoof'
}
}


stage('Snyk Test') {
steps {
sh 'echo "***RUNNING SNYK TEST***"'
sh 'snyk test --json-file-output=vuln.json || true'
sh 'snyk-filter -i vuln.json -f example-licenses-only.yml'
sh 'snyk code test'
}
}
}
}
132 changes: 132 additions & 0 deletions Snyk_GH_Issues.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import datetime
from github import Github
import json
from json2html import *
import requests

gh = Github("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")
repo = gh.get_repo("https://github.com/TSRobworld/goof")
total_snyk_issues = 0
current_gh_issues = []
split_current_issues = []
current_snyk_issues = []
open_gh_issues = []
new_issues = 0
today = datetime.date.today()
yesterday_date = today - datetime.timedelta(days=1)

# "orgs" is the Snyk orgId, and has to be a string
values = """

{
"filters": {
"orgs": ["fdf3b63a-9a4e-43d8-bae3-85212f002bea"],
"severity": [
"high",
"medium",
"low"
],
"exploitMaturity": [
"mature",
"proof-of-concept",
"no-known-exploit",
"no-data"
],
"types": [
"vuln",
"license"
],
"languages": [
"javascript"
],
"projects": [],
"issues": [],
"identifier": "",
"fixable": false,
"isFixed": false
}
}
"""

headers = {
'Content-Type': 'application/json; charset=utf-8',
'Authorization': 'da12766a-46b6-4186-8ba1-83eb1aae653c'
}

new_issues_url = 'https://snyk.io/api/v1/reporting/issues/?from=' + str(yesterday_date) + '&to=' + str(today)

results = requests.post(new_issues_url, data=values, headers=headers)

results_output = results.json()

# getting the issues from github
# taking the issues object, turning it into a string
# splitting the string to format properly
# taking that info, putting it into a list to compare the list of issues from snyk
# need to do this (for now) in order to grab the unique Snyk issue ID
open_issues = repo.get_issues(state='open')
for issue in open_issues:
issue_object_to_string = str(issue)
issue_split = issue_object_to_string[13:]
issue_list = issue_split.split('"')[0]
current_gh_issues.append(issue_list)
split_current_issues = [i.split('- ')[1] for i in current_gh_issues]


for issue in results_output['results']:
total_snyk_issues = total_snyk_issues + 1

if total_snyk_issues > 0:
print(f"Total Snyk issues found: {total_snyk_issues}")

for issue in results_output['results']:
issue_title = issue['issue']['title']
issue_type = issue['issue']['type']
issue_id = issue['issue']['id']
issue_url = issue['issue']['url']
issue_severity = issue['issue']['severity']
issue_version = issue['issue']['version']
issue_introducedDate = issue['introducedDate']
# if the issue id from the snyk API is not in the list of issues we pulled from GH
# add additional meta data to the issue, then create the issue
# using Snyk's issue ID as it's a unique identifier
# using Snyk's issue ID will prevent duplicated from being entered
if issue_id not in split_current_issues:
project_name = issue['project']['name']
project_url = issue['project']['url']
project_targetFile = issue['project']['targetFile']
new_issues = new_issues + 1

repo.create_issue(title=issue_title + " | Snyk ID - " + issue_id, body=("Title: " + issue_title) + "\n"
+ (" Snyk ID: " + issue_id) + "\n"
+ (" URL: " + issue_url) + "\n"
+ (" Severity: " + issue_severity) + "\n"
+ (" Version: " + issue_version) + "\n"
+ (" Introduced Date: " + issue_introducedDate) + "\n"
+ (" Projects with Vulnerability: " + project_name) + "\n"
+ (" Project URL: " + project_url) + "\n"
+ (" Target File: " + project_targetFile)
)

#this section closes github issues once the vulns have been fixed in Snyk:
for issue_from_snyk in results_output['results']:
snyk_issue_title = issue_from_snyk['issue']['title']
snyk_issue_type = issue_from_snyk['issue']['type']
snyk_issue_id = issue_from_snyk['issue']['id']
current_snyk_issues.append(snyk_issue_title + " | Snyk ID - " + snyk_issue_id)

for gh_open_issue in open_issues:
open_gh_issues.append(gh_open_issue.title)
if gh_open_issue.title not in current_snyk_issues:
print(gh_open_issue.title + " has been fixed in Snyk. The GitHub issue will be closed...")
gh_open_issue.edit(state='closed')

if new_issues != 0:
if new_issues > 1:
print(f"{new_issues} new issues found!")
print(f"Added {new_issues} issues to GitHub Issues")
else:
print(f"{new_issues} new issue found!")
print(f"Added {new_issues} issue to GitHub Issues")
else:
print("No new issues found since last scan.")
26 changes: 26 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- master

pool:
vmImage: ubuntu-latest

steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'

- script: |
npm install
npm run build
displayName: 'npm install and build'

- script: |
npm install -g snyk
snyk auth
snyk code test
Empty file added ci_scripts_library/__init__.py
Empty file.
Binary file not shown.
2 changes: 2 additions & 0 deletions ci_scripts_library/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .super_snyk_client import SuperSnykClient
from .github import GithubWithIssueMetadata
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading