Skip to content

Add endpoints to fetch notes/discussions for vulnerability

What does this MR do?

Related to #209990 (closed)

In this MR we add the ability in the application to fetch notes/discussions for Vulnerabilities. This is the second MR (First MR: !27515 (merged)) (and probably last one) for this feature.

Examples: GET /root/security-reports/-/security/vulnerabilities/45/discussions

[
    {
        "id": "7c624576b9354b3b394c21ba0436c2d88921f6da",
        "reply_id": "7c624576b9354b3b394c21ba0436c2d88921f6da",
        "expanded": true,
        "project_id": 19,
        "notes": [
            {
                "id": "1409",
                "type": null,
                "attachment": null,
                "author": {
                    "id": 1,
                    "name": "Administrator",
                    "username": "root",
                    "state": "active",
                    "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
                    "status_tooltip_html": null,
                    "path": "/root"
                },
                "created_at": "2020-03-23T10:58:47.058Z",
                "updated_at": "2020-03-23T10:58:47.195Z",
                "system": true,
                "noteable_id": 45,
                "noteable_type": "Vulnerability",
                "resolvable": false,
                "noteable_iid": null,
                "note": "changed vulnerability status to dismissed",
                "note_html": "<p data-sourcepos=\"1:1-1:41\" dir=\"auto\">changed vulnerability status to dismissed</p>",
                "current_user": {
                    "can_edit": false,
                    "can_award_emoji": true,
                    "can_resolve": false
                },
                "suggestions": [],
                "resolved": false,
                "resolved_by": null,
                "system_note_icon_name": "cancel",
                "discussion_id": "7c624576b9354b3b394c21ba0436c2d88921f6da",
                "emoji_awardable": false,
                "report_abuse_path": "/abuse_reports/new?ref_url=http%3A%2F%2F192.168.92.103%3A3000%2Froot%2Fsecurity-reports%2F-%2Fsecurity%2Fvulnerabilities%2F45%23note_1409&user_id=1",
                "noteable_note_url": "http://192.168.92.103:3000/root/security-reports/-/security/vulnerabilities/45#note_1409",
                "cached_markdown_version": 1310720,
                "description_version_id": null,
                "can_delete_description_version": true,
                "description_version_deleted": null,
                "human_access": "Maintainer",
                "path": "/root/security-reports/notes/1409"
            }
        ],
        "discussion_path": null,
        "individual_note": true,
        "resolvable": false,
        "resolved": false,
        "resolved_by_push": null,
        "resolved_by": null,
        "resolved_at": null,
        "diff_discussion": false,
        "for_commit": false,
        "commit_id": null
    }
]

GET /root/security-reports/-/security/vulnerabilities/45/notes

{
    "notes": [
        {
            "id": "1409",
            "type": null,
            "attachment": null,
            "author": {
                "id": 1,
                "name": "Administrator",
                "username": "root",
                "state": "active",
                "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
                "status_tooltip_html": null,
                "path": "/root"
            },
            "created_at": "2020-03-23T10:58:47.058Z",
            "updated_at": "2020-03-23T10:58:47.195Z",
            "system": true,
            "noteable_id": 45,
            "noteable_type": "Vulnerability",
            "resolvable": false,
            "noteable_iid": null,
            "note": "changed vulnerability status to dismissed",
            "note_html": "<p data-sourcepos=\"1:1-1:41\" dir=\"auto\">changed vulnerability status to dismissed</p>",
            "current_user": {
                "can_edit": false,
                "can_award_emoji": true,
                "can_resolve": false
            },
            "suggestions": [],
            "resolved": false,
            "resolved_by": null,
            "system_note_icon_name": "cancel",
            "discussion_id": "7c624576b9354b3b394c21ba0436c2d88921f6da",
            "emoji_awardable": false,
            "report_abuse_path": "/abuse_reports/new?ref_url=http%3A%2F%2F192.168.92.103%3A3000%2Froot%2Fsecurity-reports%2F-%2Fsecurity%2Fvulnerabilities%2F45%23note_1409&user_id=1",
            "noteable_note_url": "http://192.168.92.103:3000/root/security-reports/-/security/vulnerabilities/45#note_1409",
            "cached_markdown_version": 1310720,
            "description_version_id": null,
            "can_delete_description_version": true,
            "description_version_deleted": null
        }
    ],
    "last_fetched_at": 1584961214
}

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Alan (Maciej) Paruszewski

Merge request reports