EGertis462759 (Community Member) asked a question.

Is there a way to export the docker container scanning csv with an api call?

I'd like to create automation for generating JIRA tasks based on recent container scans. In order to accomplish this I'll need to be able to pull in the results from the csv. Then process the results. Then use the JIRA api to create issues based on the results from the csv. Before I spend too much time on this I'd like to know if it is feasible to pull the container scan results using an api call. Has anyone tried this?


  • EGertis462759 (Community Member)

    I figured out how to automate this with python. It would be great if we could pull the csv content in with an api call.

     

    ```

    import requests

    import json

     

    d = {}

    with open("issues.csv") as f:

    headers = [header.strip() for header in next(f).split(",")[1:]]

     

    for line in f:

    values = [value.strip() for value in line.split(",")]

    d[values[0]] = dict(zip(headers, values[1:]))

     

    for issue in d:

    if d[issue]['"Status"'] == '"Open"':

     

    library=d[issue]['"Library"'].replace('"', '')

    version_in_use=d[issue]['"Version in use"'].replace('"', '')

    issue_type=d[issue]['"Issue type"'].replace('"', '')

    latest_version=d[issue]['"Latest version"'].replace('"', '')

    project=d[issue]['"Project"'].replace('"', '')

    title=d[issue]['"Title"'].replace('"', '')

    issue_type=d[issue]['"Issue type"'].replace('"', '')

    vulnerability=d[issue]['"Title"'].replace('"', '')

    data = json.dumps({"fields": {"project":{"key": "VER"},"summary": "project:"+project+" library:"+library+" vulnerability: "+title,"description": "The following library, "+library+",is used in "+project+" which contains the following "+issue_type+" "+vulnerability,"issuetype": {"name": "Bug"}}})

    url = 'https://myjirainstance:8080/rest/api/2/issue/'

    headers = {

    'Content-Type': 'application/json'

    }

     

    response = requests.post(url,auth=('user_email,'api_key'),data=data,headers=headers)

    ```

    Expand Post

Topics (1)

No articles found
Loading

Ask the Community

Get answers, share a use case, discuss your favorite features, or get input from the community.