Import file format examples

Coverity Documentation

Version
latest
This section describes the format and attribute values of the JSON file that you must construct in order to import third-party issues into Coverity Connect, including:

JSON file - example.json

{
"header" : {
    "version" : 1,
    "format" : "cov-import-results input"
},
"sources" : [{
        "file" : "/projects/cov-import-test/doc_example/missing_indent_source.c",
        "encoding" : "ASCII",
        "language" : string
    },
    {
        "file" : "/projects/cov-import-test/doc_example/too_many_characters.c",
        "encoding" : "ASCII"
    }
],
"issues" : [{
    "checker" : "bad_indent",
    "extra" : "bad_indent_var",
    "file" : "/projects/cov-import-test/doc_example/missing_indent_source.c",
    "function" : "do_something",
    "subcategory" : "small-mistakes",
    "domain" : string
    
    "properties" : {
        "type" : "Type name",
        "category" : "Category name",
        "impact" : "Medium",
        "cwe" : 123,
        "longDescription" : "long description",
        "localEffect" : "local effect",
        "issueKind" : "QUALITY"
    },    
    "events" : [{
        "tag" : "missing_indent",
        "description" : "Indent line with 8 spaces (do not use Tab)",
        "linkUrl" : "http://www.blackduck.com/",
        "linkText" : "Black Duck Software, Inc Web page",  
        "line" : 19,
        "main" : true
        }
    ] },
{
    "checker" : "line_too_long",
    "extra" : "line_too_long_var",
    "file" : "/projects/cov-import-test/doc_example/too_many_characters.c",
    "function" : "do_something_else",
    "subcategory" : "small-mistakes",
    "events" : [
        {
        "tag" : "long_lines",
        "description" : "This line exceeds the 80 character limit",
        "linkUrl" : "http://www.blackduck.com/",
        "linkText" : "Black Duck Software, Inc Web page",
        "line" : 4,
        "main" : true
        }
    ] }
] }

Source file 1 - missing_indent_source.c

#include <stdio.h>

int main(int argc, const char * argv[])
{
    int limit=10;
    int res = 0;

    res = do_something (limit);

    printf ("The final count for l was %d\n",res);

    return 0;
}

int do_something (int limit) {
    int i=0, l=0;

    for (i=0;i<limit;i++){
        l+=i;
    }

    return l;
}

Source file 2 - too_many_characters.c

#include  <stdio.h>

int do_something_else () {
	printf("This is an example of a pretty long line, which will exceed the 80 character rule"); 
}