Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 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
35b3ba6
Update snowflakestuff.yml
Robthreefold Jun 28, 2022
9103dc8
Update snowflakestuff.yml
Robthreefold Jun 28, 2022
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
  •  
  •  
  •  
33 changes: 33 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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: [push]

permissions:
contents: read

env:
REMOTE_REPO_URL: ${{ secrets.REMOTE_REPO_URL }},
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }},
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.9.5"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install attrs
- name: Create and delete GitHub issues based off of Snyk projects
run: python ci-scripts-library/ci_scripts_library/snyk_scm_issues_to_gh_issues/cli.py sync_issues
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: pull_request
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/goof/goof/*.html /home/runner/work/goof/goof/downloads
- name: Run Snyk test
uses: actions/upload-artifact@v2
with:
name: results
path: downloads
13 changes: 13 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,13 @@
name: snyk-labs/action example - Snyk SCM Issues to Github Issues
on: workflow_dispatch
# - push
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: snyk-labs/actions/snyk-scm-issues-to-gh-issues@main

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
Loading