Giter Site home page Giter Site logo

jira-tickets-for-new-vulns's Introduction

Open Jira tickets for new & existing Snyk project issues

Sync your Snyk monitored projects and open automatically JIRA tickets for new issues and existing one(s) without ticket already created. Run this after snyk monitor in CI or every day/hour for non CLI projects. Aimed to be executed at regular interval or with a trigger of your choice (webhooks).

CircleCI Inactively Maintained

This repository is in maintenance mode, no new features are being developed. Bug & security fixes will continue to be delivered. Open source contributions are welcome for small features & fixes (no breaking changes)

Installation

You can either download the binaries from the the release page or Use go install github.com/snyk-tech-services/jira-tickets-for-new-vulns@latest

Usage - Quick start

  • --orgID required

    Public Snyk organization ID can be located in the organization settings

    Example: --orgID=0e9373a6-f858-11ec-b939-0242ac120002

  • --token required

    Create a service account in Snyk and use the provided token.

    Example: --token=0e9373a6-f858-11ec-b939-0242ac120002

  • --jiraProjectKey required

    Jira project key the tickets will be opened against.

    Example: --jiraProjectKey=TEAM_A

Example:

./snyk-jira-sync-linux --orgID=0e9373a6-f858-11ec-b939-0242ac120002 --token=xxxxxxxx-xxxx-xxxx-xxxx-0242ac120002 --jiraProjectKey=TEAM_A

Extended options

  • --orgID required

    Public Snyk organization ID can be located in the organization settings

    Example: --orgID=0e9373a6-f858-11ec-b939-0242ac120002

  • --token required

    Create a service account in Snyk and use the provided token.

    Example: --token=0e9373a6-f858-11ec-b939-0242ac120002

  • --jiraProjectKey required

    Jira project key the tickets will be opened against.

    Example: --jiraProjectKey=TEAM_A

  • --jiraProjectID optional

    jiraProjectKey or jiraProjectID must be set, but not both. This is an alternative way to specify a Jira project.

    Example: --jiraProjectKey=1234

  • --projectID optional

    By default all projects in a given Snyk organization will be synced, if projectID is set only this project will be synced. Project public ID can be located in project settings

    Example: --projectID=0e9373a6-f858-11ec-b939-0242ac120002

  • --api optional

    Alternative API host.

    Example: --api=https://my.private.instance.com/api

  • --jiraTicketType optional

    Type of ticket to open. Defaults to Bug. Must match the issue type configured in the provided Jira project.

    Example: --jiraTicketType=Defect

  • --severity optional

    Severity threshold to open tickets for. Can be one of critical, high, medium, low. Defaults to low. Example: --severity=critical

  • --maturityFilter optional

    Can be one or multiple values: mature, proof-of-concept, no-known-exploit, no-data. Note: Not supported for Snyk Code

    Example: --maturityFilter=[mature,no-data]

  • --type optional

    Snyk issue type to open tickets for. Defaults to all. Possible values: all, vuln, license

    Example: --type=vuln

  • --assigneeId optional

    Jira ID of user to assign tickets to.

    Example: --assigneeId=123abc456def789

  • DEPRECATED --assigneeName optional

    Currently Snyk supports Jira API v2 where this field is now deprecated. See the Jira deprecation notice.

  • --priorityIsSeverity optional

    Set the ticket priority to be based on severity, default priorities & severities: Low|Medium|High|Critical=>Low|Medium|High|Highest. Can be true or false.

    Example: --priorityIsSeverity=true

  • --labels optional

    Set Jira ticket labels

    Example: --labels=app-1234

  • --dueDate optional

    Set Jira ticket labels

    Example: --dueDate=2022-12-01

  • --priorityScoreThreshold optional

    Your minimum Snyk priority score threshold. Can be a number between 0 and 1000.

    Example: --priorityScoreThreshold=700 [0-1000]

  • --dryRun optional

    Enables dry run mode, which will not open any tickets but provide information on what changes will occur. Results can be found in a json log file in the same directory.

    Example: --dryRun=true

  • --debug optional

    Enables debug mode. For more comprehensive debug information from Go set the environment variable GODEBUG=http2debug=2 as well.

    Example: --debug=true

  • --cveInTitle optional

    Enables the CVEs as suffix in the Jira ticket title.

    Example: --cveInTitle=true Note: Not supported for Snyk Code

  • --ifUpgradeAvailableOnly optional

    Only create tickets for vuln issues that are upgradable.--type must be set to all or vuln for this to work.

    Example: --ifUpgradeAvailableOnly=true

  • --projectCriticality optional

    Include only projects whose Snyk business criticality attribute contains one or more of the specified values. This should be all lower case, comma separated with no spaces.

    Example: --projectCriticality=critical,medium

  • --projectEnvironment optional

    Include only projects whose Snyk environment attribute contains one or more of the specified values. This should be all lower case, comma separated with no spaces.

    Example: --projectEnvironment=backend,frontend

  • --projectLifecycle optional

    Include only projects whose Snyk lifecycle attribute contains one or more of the specified values. This should be all lower case, comma separated with no spaces.

    Example: --projectLifecycle=development,production

  • --configFile optional

    Path the directory where jira.yaml file is located (by default we will check current directory)

    Example: --configFile=/directory-name

  • --ifAutoFixableOnly optional

    Only create tickets for vuln issues that are fixable (no effect when using ifUpgradeAvailableOnly).--type must be set to all or vuln for this to work.

    Example: --ifAutoFixableOnly=true

Restrictions

The tool does not support IAC project. It will open issue only for code and open source projects and ignore all other project type.

Priority is Severity

Option to get the JIRA ticket priority set based on issue severity. Defaults map to:

Issue severity JIRA priority
critical Highest
high High
medium Medium
low Low

Use SNYK_JIRA_PRIORITY_FOR_XXX_VULN env var to override the default an set your value.

Example: Critical sevs should receive the Hot Fix priority in JIRA

export SNYK_JIRA_PRIORITY_FOR_CRITICAL_VULN='Hot Fix'

Installation from source

git clone the repo, build.

go run main.go jira.go jira_utils.go vulns.go snyk.go snyk_utils.go

Please report issues.

Dependencies

https://github.com/michael-go/go-jsn/jsn to make JSON parsing a breeze github.com/tidwall/sjson github.com/kentaro-m/blackfriday-confluence gopkg.in/russross/blackfriday.v2

LogFile

A logFile listing all the tickets created can be found where the tool has been run.

{
  "projects": {
    "123": [
      {
        "Summary": "test/goof:package.json - Remote Code Execution (RCE)",
        "Description": "\r\n \\*\\*\\*\\* Issue details: \\*\\*\\*\\*\n\r\n cvssScore:  8.10\n exploitMaturity:  proof\\-of\\-concept\n severity:  high\n pkgVersions: 3.0.0\\]\n\r\n*Impacted Paths:*\n\\- \"snyk\"@\"1.228.3\" =\u003e \"proxy\\-agent\"@\"3.1.0\" =\u003e \"pac\\-proxy\\-agent\"@\"3.0.0\" =\u003e \"pac\\-resolver\"@\"3.0.0\"\n\r\n[See this issue on Snyk|https://app.snyk.io/org/test/project/123]\n\n[More About this issue|https://security.snyk.io/vuln/SNYK-JS-PACRESOLVER-1589857]\n\n",
        "JiraIssueDetail": {
          "JiraIssue": {
            "Id": "10001",
            "Key": "FPI-001"
          },
          "IssueId": "SNYK-JS-PACRESOLVER-1589857"
        }
      },
      {
        "Summary": "test/goof:package.json - Prototype Pollution",
        "Description": "\r\n \\*\\*\\*\\* Issue details: \\*\\*\\*\\*\n\r\n cvssScore:  6.30\n exploitMaturity:  proof\\-of\\-concept\n severity:  medium\n pkgVersions: 4.2.0\\]\n\r\n*Impacted Paths:*\n\\- \"snyk\"@\"1.228.3\" =\u003e \"configstore\"@\"3.1.2\" =\u003e \"dot\\-prop\"@\"4.2.0\"\n\r\\- \"snyk\"@\"1.228.3\" =\u003e \"update\\-notifier\"@\"2.5.0\" =\u003e \"configstore\"@\"3.1.2\" =\u003e \"dot\\-prop\"@\"4.2.0\"\n\r\n[See this issue on Snyk|https://app.snyk.io/org/test/project/123]\n\n[More About this issue|https://security.snyk.io/vuln/SNYK-JS-DOTPROP-543499]\n\n",
        "JiraIssueDetail": {
          "JiraIssue": {
            "Id": "10001",
            "Key": "FPI-001"
          },
          "IssueId": "SNYK-JS-DOTPROP-543499"
        }
      },
    ]
  }
}

Jira.yaml

Example of config file structure. If your jira project has specific required field or custom fields configured, they will need to be added to the config file. Mandatory fields:

  • Make sure to give both key and value expected by jira under the customMandatoryField key of the config file. We support 2 kind of required field: simple key/value pair or nested key/value

  • Simple key/Value:

      customMandatoryFields:
            key:
              value: "This is a summary"
    

    will result in adding this object to the ticket {"key":{"Value":"This is a summary"}

  • Nested:

    firstKey:
          secondKey:
            id: 65
    

    will result in adding this object to the ticket "firstKey":{"secondKey":{"id":62}}

Custom fields:

At the moment we are supporting 3 types of custom Jira fields: labels, MultiGroupPicker and MultiSelect.

Make sure to respect the format in the config file:

  • simpleField: "customfield_10601": value: jiraValue-simpleField-something to add to the ticket will be sent as "customfield_10601":"something to add to the ticket"
  • labels: "customfield_10601": value: jiraValue-label-Value1,Value2 will be sent as "customfield_10601":["Value1","Value2"]
  • MultiGroupPicker: "customfield_10601": value: jiraValue-MultiGroupPicker-Value1,Value2 will be sent as "customfield_10601":[{"name":"Value1"},{"name":"Value2"}]
  • MultiGroupPicker: "customfield_10601": value: jiraValue-MultiSelect-Value1,Value2 will be sent as "customfield_10601":[{"value":"Value1"},{"value":"Value2"}]

For more details on jira custom field please visit Jira documentation

schema: 1
snyk:
    orgID: a1b2c3de-99b1-4f3f-bfdb-6ee4b4990513 # <SNYK_ORG_ID>
    projectID: a1b2c3de-99b1-4f3f-bfdb-6ee4b4990514 # <SNYK_PROJECT_ID>
    severity: critical # <critical|high|medium|low>
    maturityFilter: mature # <mature,proof-of-concept,no-known-exploit,no-data>
    type: all # <all|vuln|license>
    priorityScoreThreshold: 10
    api: https://myapi # <API endpoint> default to
    ifUpgradeAvailableOnly: false # <true|false>
jira:
    jiraTicketType: Task # <Task|Bug|....>
    jiraProjectID: 12345
    assigneeId: 123abc456def789
    priorityIsSeverity: true # <true|false>
    labels: label1 # <IssueLabel1>,<IssueLabel2>
    jiraProjectKey: testProject
    priorityIsSeverity: false # <true|false> (defaults: Low|Medium|High|Critical=>Low|Medium|High|Highest)
    customMandatoryFields:
        key:
            value: 5
        customfield_10601:
          value: jiraValue-MultiGroupPicker-Value1,Value2
        customfield_10602:
          value: jiraValue-simpleField-something to add to the ticket

Notes:

  • The token is not expected present in the config file
  • Command line arguments override the config file. IE: Using the config file above, running ./snyk-jira-sync-macOs --Org=1234 --configFile=./path/to/folder --token=123 the org ID used by the tool will be 1234 and not a1b2c3de-99b1-4f3f-bfdb-6ee4b4990513
  • See 'Extended options' for default values

jira-tickets-for-new-vulns's People

Contributors

aarlaud avatar ilantsnyk avatar jeff-snyk avatar jlourenc avatar lili2311 avatar mathild3r avatar olegshprengelsnyk avatar scott-es avatar vallieres avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jira-tickets-for-new-vulns's Issues

Only open ticket when issue is upgradable and patchable.

Hi Team,

Is there a way I can only open the ticket if the vulnerability is either upgradable or patchable? Something like the flag --fail-on=all (https://docs.snyk.io/snyk-cli/commands/test#fail-on-less-than-all-or-upgradable-or-patchable-greater-than)

Currently, I can only see one option --ifUpgradeAvailableOnly that creates tickets for vuln that are upgradable, but this doesn't cover patchable issues. Is there a way I can do that? Is this a flag not yet included in the code or am I missing something?

Thanks

Unable to create JIRA tickets

Hi Team
I'm trying to create JIRA ticket, but facing the error mentioned in screenshot, tried using --debug flag to get some error info but not really able to figure the issue from same. Is there something I should be doing differently?

Screenshot 2022-05-18 at 7 06 59 PM

Here is the command I've used
./snyk-jira-sync-macos --token=<token> --orgID=1<orgID> --projectID=<projectID> --dryRun=true --configFile=<configFileDir> --debug=true

Errors with "/bin/" in summary of the Jira Issue get caught by WAF, failing HTTP request to Snyk API when creating new vulnerabilities

When this tool encounters a project with a vulnerability that has a title of "/bin/" in the title in Snyk, it will fail creating the issue with a nondescript error code, as shown below:

*** ERROR *** Please check the format config file unexpected end of JSON input
open : no such file or directory
*** ERROR *** Could not read file at location: . Please ensure the file exists and is formatted correctly.
ERROR: open: no such file or directory

image

This is misleading, since it is not a JSON error, but rather a HTTP Error code 403 response, since I can reproduce this error in the Snyk Web UI by finding the project in question, obtained from the above log (the last "Step 1/4 - Retrieving project <PROJECT_UUID>" message) and pressing the "Create a Jira Issue" for the vulnerability for this. This will just print out "Failed to create the Jira issue" and log a network request error with the 403 response code as shown below:

POST https://app.snyk.io/org/<MY_ORGANIZATION>/project/<PROJECT_UUID>/issue/SNYK-GOLANG-GITHUBCOMGOGITGOGITV5-6150754/jira/new
image
image

With the response content of:

Access Denied
You don't have permission to access "http://app.snyk.io/org/<MY_ORGANIZATION>/project/<PROJECT_UUID>/issue/SNYK-GOLANG-GITHUBCOMGOGITGOGITV5-6150754/jira/new" on this server.

Reference #18.e6e22517.1713957523.146c0bb9

https://errors.edgesuite.net/18.e6e22517.1713957523.146c0bb9

Suggestion:

1:
Handle HTTP errors relating to the Web Application Firewall, which fails with HTTP Error code 403, likely to prevent Path Traversal attacks.

Perhaps continue with the rest of the tasks after this failure and perhaps print out the failed task in the end?

2:
Otherwise, a solution could be to change the summary of the To Be Created Jira Issue, to sanitize and remove illegal character combinations. For example, what worked for this specific issue was to replace the "/bin/" part of the issue summary to something like "bin", like so:
Original: <APP_ORG_NAME>/deployment.apps/<APP_NAME>:/usr/local/bin/<APP_NAME> - Path Traversal in github.com/go-git/go-git/v5
Sanitized: <APP_ORG_NAME>/deployment.apps/<APP_NAME>:/usr/local_bin_<APP_NAME> - Path Traversal in github.com/go-git/go-git/v5

I tested this sanitazion, and successfully created a Jira Issue with the following cURL:
curl 'https://app.snyk.io/org/<MY_ORGANIZATION>/project/<PROJECT_UUID>/issue/SNYK-GOLANG-GITHUBCOMGOGITGOGITV5-6150754/jira/new' -X POST --data-raw '{"projectId":"x","issueTypeId":"x","assignee":null,"summary":"<APP_ORG_NAME>/deployment.apps/<APP_NAME>:/usr/local_bin_<APP_NAME> - Path Traversal in github.com/go-git/go-git/v5", ...}'

A weird thing, the summary cannot contain "/bin/" but the description can contain "/bin/" just fine? Strange behavior.

Unable to execute the utility

Hi the latest version is not executing for me.
It fails with the error:

*** ERROR *** config file not found
2022/04/20 19:08:51 *** ERROR *** Missing mandatory flags &{ https://snyk.io/api

Command:
./snyk-jira-sync-macos --token {} --priorityIsSeverity --jiraProjectKey AR --debug --dryrun --orgID {}

even running ./snyk-jira-sync-macos --help throws same error

--severity flag not working as expected

Hi Team
While using --severity flag along with command, it is not working as expected for lower priorities , it takes all higher priorities as well. While it should only use the severity passed with flag by user
For eg:
--severity: critical (creates ticket for critical issues)
--severity: high (creates ticket for critical and high issues while it should create tickets for high issues)
--severity: medium (creates ticket for critical, high and medium issues while it should create tickets for medium issues)
--severity: low (creates ticket for critical, high, medium and high issues while it should create tickets for low issues)

Vulnerability in Release 5.1.0

The library golang.org/x/text version 0.3.7 was detected in Golang binary located at /snyk-jira-sync-linux and is vulnerable to CVE-2022-32149, which exists in versions <0.3.8.

The vulnerability was found in the The Go Vulnerability Database with vendor severity: High (NVD severity: High).

Note: If this library is owned by a 3rd party vendor (e.g. open source library), follow the vendor's release-notes to check remediation options.

Feature Request: Create a single Jira ticket per Snyk target

Rather than creating a single Jira ticket per Snyk project issue, there should be an option to create a single Jira ticket per Snyk target. For example, if the Snyk target snyk/goof has 3 vulnerabilities with critical severity and mature exploit-ability, enabling this toggle would allow for the creation of a single Jira ticket including the Snyk project issue links for all 3 tickets. This example assumes the optional severity and maturity were used.

Not Creating License Issue ticket

Hi Team,

I have noticed an issue with the code: the IssueType=License is not parsed correctly. If you look at the code here https://github.com/snyk-tech-services/jira-tickets-for-new-vulns/blob/develop/vulns.go#L177, it is parsing

for _, e := range j.K("issues").K("licenses").Array().Elements() {

for the type: license flag. But this will never parse the Snyk log correctly because
a) its license, not licenses and
b) the key is issueType not issue

I used the below output of the aggregated-issue API call from the code. As you can see even though I have a license issue matching the filter I am passing, it is not creating the Jira ticket.

`2022/07/10 10:50:55 *** INFO *** Body : {"filters":{"severities":["critical","high"],"priority":{"score":{"min":0,"max":1000}},"types":["license"],"ignored":false,"patched":false}}

2022/07/10 10:50:55 ************************* AGGREGATED ISSUE OUTPUT *******************************************
2022/07/10 10:50:55 {map[issues:[map[fixInfo:map[isFixable:false isPartiallyFixable:false isPatchable:false isPinnable:false isUpgradable:false nearestFixedInVersion:] id:XXXXX:false isPatched:false issueData:map[exploitMaturity:no-data id:XXXX isMaliciousPackage:false language:js nearestFixedInVersion: publicationTime:2022-07-03T18:02:34.595Z semver:map[vulnerable:[>=0]] severity:high title:xxxx url:https://snyk.io/vuln/xxxx] issueType:license links:map[paths:https://app.snyk.io/api/v1/org/xxxx/project/xxxx/history/xxxx/issue/xxxx/paths] pkgName:xx pkgVersions:[xx] priority:map[factors:[map[description:Recently disclosed name:isFresh] map[description:High severity name:severity]] score:625] priorityScore:625]]] true}
2022/07/10 10:50:55 ********************************************************************

2022/07/10 10:50:55 *** INFO *** List of vuln without tickets: map[]
2022/07/10 10:50:55 *** INFO *** Step 4/4 - No new Jira ticket required`

A simple fix is copying the parsing of vulnerability and changing to following

for _, e := range listOfIssues {
		if e.K("issueType").String().Value == "license" 

Problem creating jiraIssue

The script sends a post request for endpoint /api/v1/org/{orgID}/project/{projectID}/issue/{issueID}/jira-issue and return a exception error entity.parse.failed with http status code 400 bad request.

I read the documentation for create-jira-issue and it shows they are exactly the same attributes being passed in the request on line 179 of the jira.go.

I think the problem is in the request body in the description attribute.

Request body
{ "fields": {"project": {"id":"{projectID}"} ,"summary":"generic/project/name - Cross-Site Request Forgery (CSRF)", "description":"\r\n \\*\\*\\*\\* Issue details: \\*\\*\\*\\*\n\r\n Title: Cross\\-Site Request Forgery \\(CSRF\\)\n Summary: CSRF protection is disabled by setting the value to \\_. This allows the attackers to execute requests on a user's behalf.\n Severity: low\n PriorityScore: 434\n PriorityScoreFactors:\n \\- Found in multiple sources\n \\- Found in a file appearing in multiple code flows\n \\- Has fix examples available \r\n *_Impacted file:_*\n\r {impactedFile}\n \\- startLine: 32\n \\- startColumn: 9\n \\- endLine: 32\n \\- endColumn: 38\n\n[See this issue on Snyk|https://app.snyk.io/org/{org}/project/{projectId}]\n\n", "issuetype":{ "name":"Bug"} }

Response body
{"expose":true,"statusCode":400,"status":400,"body":"{ \"fields\": {\"project\": {\"id\":\"number\"} ,\"summary\":\"generic/project/name - Cross-Site Request Forgery (CSRF)\", \"issuetype\":{ \"id\":\"number\"} } ","type":"entity.parse.failed"}

Please can you help me?

Utility doesn't work in kubernetes

Hi,

I created a docker image in order to run the utility in in one of our kubernetes clusters. The image builds just fine but when I try to run it in kubernetes I get the following:

2022/06/30 03:29:41 *** INFO *** Project ID not specified - listing all projects that match the following filers:  projectCriticality:
 projectEnvironment:
 projectLifecycle:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x8442d1]

goroutine 1 [running]:
main.makeSnykAPIRequest(0x93ef2d, 0x3, 0xc00002c230, 0x48, 0x7ffff3a54dc2, 0x24, 0x0, 0x0, 0x0, 0xc00002c200, ...)
	/home/circleci/project/snyk_utils.go:38 +0x441
main.getOrgProjects(0xc000024510, 0x24, 0x9489a2, 0x13, 0x7ffff3a54dc2, 0x24, 0x0, 0x0, 0xc000028eb8, 0x4, ...)
	/home/circleci/project/snyk.go:65 +0x1a7
main.getProjectsIds(0xc000024510, 0x24, 0x9489a2, 0x13, 0x7ffff3a54dc2, 0x24, 0x0, 0x0, 0xc000028eb8, 0x4, ...)
	/home/circleci/project/snyk.go:90 +0x1ac
main.main()
	/home/circleci/project/main.go:24 +0x104

Here's my Dockerfile

FROM alpine:3

ENV VERSION 1.29.0
WORKDIR /snyk
RUN wget -q https://github.com/snyk-tech-services/jira-tickets-for-new-vulns/releases/download/${VERSION}/snyk-jira-sync-linux
ENV PATH /snyk:$PATH
COPY jira.yaml /snyk/
COPY entrypoint.sh /snyk/
RUN apk add --no-cache libc6-compat gcompat su-exec && \
    chmod +x snyk-jira-sync-linux entrypoint.sh

ENTRYPOINT ["/snyk/entrypoint.sh"]

And my entrypoint.sh:

#!/bin/sh

if [[ -z $SNYK_API_TOKEN ]];then
    echo "SNYK_API_TOKEN variable required."
    exit 1
fi

su-exec nobody /snyk/snyk-jira-sync-linux --configFile=/snyk --token=${SNYK_API_TOKEN} --debug=${DEBUG:false}

Any help/insight you can provide would be welcome.

New flag request: --canAutoPR

When trying to use the --isUpgradeAvailableOnly flag to try to only create Jira tickets for fixable problems, I hit the issue of tickets with fixes not being created.

Upon checking the API, I found that the reason was simple: tickets with patches available had isUpgradable set to False, but isFixable set to true.

Suggestion: To prevent breaking things for customers depending on the current implementation of --isUpgradeAvailableOnly, create a second flag (optimally incompatible with each other) called --canAutoPR which would pass if any of the fixInfo fields are true - which I believe would cover any issue that can have an automated PR generated by snyk.

As far as I can tell, the code to add to is mostly here - but I don't know golang well enough to produce a PR.
https://github.com/snyk-tech-services/jira-tickets-for-new-vulns/blob/develop/jira.go#L247

Json response from https://app.snyk.io/api/v1/org/$ORG_ID/project/$PROJECT_ID/aggregated-issues:

{
	"issues": [
		{
			"id": "SNYK-PYTHON-DJANGO-2606969",
			"issueType": "vuln",
			"pkgName": "django",
			"pkgVersions": [
				"3.2"
			],
			"priorityScore": 811,
			"priority": {
				"score": 811,
				"factors": [
					{
						"name": "exploitMaturity",
						"description": "Proof of Concept exploit"
					},
					{
						"name": "isFixable",
						"description": "Has a fix available"
					},
					{
						"name": "cvssScore",
						"description": "CVSS 9.8"
					}
				]
			},
			"issueData": {
				"id": "SNYK-PYTHON-DJANGO-2606969",
				"title": "SQL Injection",
				"severity": "critical",
				"url": "https://snyk.io/vuln/SNYK-PYTHON-DJANGO-2606969",
				"identifiers": {
					"CVE": [
						"CVE-2022-28346"
					],
					"CWE": [
						"CWE-89"
					]
				},
				"credit": [
					"Preston Elder",
					"Jacob Davis",
					"Jacob Moore",
					"Matt Hanson",
					"David Briggs",
					"and Danylo Dmytriiev"
				],
				"exploitMaturity": "proof-of-concept",
				"semver": {
					"vulnerable": [
						"[,2.2.28)",
						"[3.0,3.2.13)",
						"[4.0,4.0.4)"
					]
				},
				"publicationTime": "2022-04-11T16:03:04Z",
				"disclosureTime": "2022-04-11T12:17:04Z",
				"CVSSv3": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:P",
				"cvssScore": 9.8,
				"cvssDetails": [
					{
						"assigner": "NVD",
						"severity": "critical",
						"cvssV3Vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
						"cvssV3BaseScore": 9.8,
						"modificationTime": "2022-11-08T01:10:40.472234Z"
					}
				],
				"language": "python",
				"patches": [],
				"nearestFixedInVersion": "",
				"isMaliciousPackage": false
			},
			"isPatched": false,
			"isIgnored": false,
			"fixInfo": {
				"isUpgradable": false,
				"isPinnable": true,
				"isPatchable": false,
				"isFixable": true,
				"isPartiallyFixable": true,
				"nearestFixedInVersion": "",
				"fixedIn": [
					"2.2.28",
					"3.2.13",
					"4.0.4"
				]
			},
			"links": {
				"paths": "https://app.snyk.io/api/v1/org/REDACTED/project/REDACTED/history/REDACTED/issue/SNYK-PYTHON-DJANGO-2606969/paths"
			}
		}
	]
}

Reproduction steps:

Create a git repo with a single file, requirements.txt that has the following contents:

django==3.2

Scan the repo with snyk, in an org with jira integration enabled

Try to call this script against that project with the --isUpgradeAvailableOnly flag set

Optional parameter severity is not so optional

We are just spinning this up internally to create all tickets and when testing using the arguments in the example in the readme we would get an error on a projects that did not have dependencies for instance kubernetes deployment yaml.

*** ERROR *** Could not get aggregated data from https://snyk.io/api org ####-###-###-###-### project ###-###-###-###-### issue ####

Enabling the debug log there is a 404 on that project API endpoint

2021/12/29 10:07:48 *** ERROR *** Request on endpoint 'https://snyk.io/api/v1/org/####-###-###-###-###/project/###-###-###-###-### /issue/####/paths' failed with error 404 Not Found

Adding in the severity argument allowed the software to work as expected.

Filter out inactive projects

Whenever I run the sync tickets get created for projects that are marked as inactive. Is there a way to tell the utility to skip those? Additionally, it'd be nice to have an include and/or exclude filter based on tag(s).

I'm running v3.35.1 if that helps.

Error when setting dueDate "snyk-jira-sync-linux --dueDate=2023-10-20"

Noticed in jira.go line no 34DueDate string json:"dueDate,omitempty", dueDate is mapped wrongly . It should be changed with duedate string json:"duedate,omitempty"

2023/07/22 05:38:46 *** ERROR *** VulnID SNYK-JS-HOSTEDGITINFO-10xx3xx ticket not created : Request to /v1/org/aexxxaf9-xxxx-4faa-aedb-c806a9xxx8a/project/cexxx71-xx38-xx6a-9f10-446xxxxxa9/issue/SNYK-JS-HOSTEDGITINFO-10xx3xx/jira-issue failed with : Unprocessable Entity, Request failed

Print out error message when no ErrorsFile can be found

Created from issue #211

When debugging a separate problem, I couldn't understand the actual problem, since there was no error message outputted. As shown below, it just prints out a generic "no such file or directory":
325196728-a3d19940-ba27-46e5-9015-b0e03e88161d

ERROR Please check the format config file unexpected end of JSON input
no such file or directory
Could not read file at location: .
Please ensure the file exists and is formatted correctly.
ERROR no such file or director

It turns out it was because I ran the binary in a Docker Image, and I think it was missing some permissions to write the ErrorsFile.
And when the code runs into an error and tries to print out a failure message, if the ErrorsFile cannot be read/found in the "writeErrorFile" function here: https://github.com/snyk-tech-services/jira-tickets-for-new-vulns/blob/develop/utils.go#L371
Then it will fail with the above shown message about it not being able to read the file.
The errors in the "writeErrorFile" are not handled, and this makes sense, since it usually does not make sense to print errors when trying to read error messages.

But my suggestion is to just output a generic error message, saying that no files were found when looking for other errors.

Issue while creating customMandatoryFields

Hi,

I am trying to add our custom Jira field called "Line of Business" in the jira.yaml file but not sure how to do it. I have tried all the below methods, but everything gave me the same error (except the last one):

2022/03/27 15:47:23 *** INFO *** Please check that all expected fields are present in the config file
2022/03/27 15:47:23 *** INFO *** Details : {"error":"Field 'value' cannot be set. It is not on the appropriate screen, or unknown., Field 'key' cannot be set. It is not on the appropriate screen, or unknown."}
2022/03/27 15:47:23 *** ERROR *** Request failed
  1. Jira.yaml
  customMandatoryFields:
        key: 
            Value: Security Team
        transition: 
            id: 12345 <- this is the id of the field in jira
  1. Jira.yaml
  customMandatoryFields:
    key: "Line of Business"
    value: "Security Team"
  1. Jira.yaml
  customMandatoryFields:
        12345: 
            Value: Security Team
  1. Jira.yaml
  customMandatoryFields:
        components: [{"Line of Business": Security Ratings}]

Error

2022/03/27 16:18:04 *** ERROR *** Could not Marshalled new ticket, mandatory fields will no the added json: unsupported type: map[interface {}]interface {}
2022/03/27 16:18:04 *** INFO *** Request on endpoint 'https://snyk.io/api/v1/org/orgID/project/projectid/issue/issueid/jira-issue' failed with error 422 Unprocessable Entity

Can you please help me with it?

Weird ERROR coming from snyk API

Hi folks,

I'm running jira-tickets-for-new-vulns binary every day and since a while we are receiving the following error while scanning ECR container images project:

2023/01/25 11:03:06 *** ERROR *** Could not get paths data from https://snyk.io/api org MY-ORG-ID project MY-PROJECT-ID issue SNYK-UPSTREAM-NODE-3035795

That is preventing the tool to create the jira ticket for the issue.

Any help would be appreciated.
Thanks,

CustomMandatory Fields does not support Datetime formats

The default date time format for JIRA is "2011-10-19T10:29:29.908+1100" which has hyphen and only considering 2011 when passed as custom filed.

jira_utils.go
supportJiraFormats() method split strings is using - , this need to be changed to support date time format

ERROR could not get aggregated data from https://snyk.io/api org Request failed

It runs fine until it hits a specific project... Then it throws an error that is not verbose enough.

snyk-jira-sync --projectID XXXXX --orgID=$SNYK_ORGID --jiraProjectKey=SEC --severity=high --configFile ./ --type=vuln --token=$SNYK_API_KEY --labels=snyk,vulnerability,high --priorityIsSeverity=P2 --debug
2022/04/23 02:01:29 *** INFO *** 1/4 - Retrieving Project XXXXX
2022/04/23 02:01:29 *** INFO *** 2/4 - Getting Existing JIRA tickets
2022/04/23 02:01:30 *** INFO *** 3/4 - Getting vulns
2022/04/23 02:01:30 *** ERROR *** Could not get aggregated data from https://snyk.io/api org XXXXXX project XXXXX issue SNYK-UPSTREAM-NODE-1315789
2022/04/23 02:01:30 Request failed

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.