Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch deletion handling with Bitbucket Server #644

Closed
nleach999 opened this issue Feb 17, 2021 · 1 comment · Fixed by #932
Closed

Branch deletion handling with Bitbucket Server #644

nleach999 opened this issue Feb 17, 2021 · 1 comment · Fixed by #932
Labels
enhancement New feature or request

Comments

@nleach999
Copy link
Contributor

Describe the problem

Newer versions of BitBucket server send a push event that indicates branch deletion. Currently, we don't gracefully handle this because the scan logic is attempted. If it is a branch name meeting the protected branch name criteria, it fails to scan because the branch is deleted.

This means we also don't handle the project deletion the same way as other SCMs.

Proposed solution

Implement the same logic as in GitHub to not scan delete push events and to delete SAST projects for the branch.

Additional details

This is an example payload from BB server 7.10.0. Note the "changes" section.

{
    "eventKey": "repo:refs_changed",
    "date": "2021-02-17T17:18:47+0000",
    "actor": {
        "name": "admin",
        "emailAddress": "[email protected]",
        "id": 2,
        "displayName": "admin",
        "active": true,
        "slug": "admin",
        "type": "NORMAL",
        "links": {
            "self": [
                {
                    "href": "http://localhost:7990/users/admin"
                }
            ]
        }
    },
    "repository": {
        "slug": "simplyvulnerable",
        "id": 1,
        "name": "simplyvulnerable",
        "hierarchyId": "781fefd15bfb01738bb9",
        "scmId": "git",
        "state": "AVAILABLE",
        "statusMessage": "Available",
        "forkable": true,
        "project": {
            "key": "TEST",
            "id": 1,
            "name": "TEST",
            "public": false,
            "type": "NORMAL",
            "links": {
                "self": [
                    {
                        "href": "http://localhost:7990/projects/TEST"
                    }
                ]
            }
        },
        "public": false,
        "links": {
            "clone": [
                {
                    "href": "ssh://git@localhost:7999/test/simplyvulnerable.git",
                    "name": "ssh"
                },
                {
                    "href": "http://localhost:7990/scm/test/simplyvulnerable.git",
                    "name": "http"
                }
            ],
            "self": [
                {
                    "href": "http://localhost:7990/projects/TEST/repos/simplyvulnerable/browse"
                }
            ]
        }
    },
    "changes": [
        {
            "ref": {
                "id": "refs/heads/demo-dev",
                "displayId": "demo-dev",
                "type": "BRANCH"
            },
            "refId": "refs/heads/demo-dev",
            "fromHash": "3cf2a5016a71ff880ed62a7058bdfdbd620fe6ab",
            "toHash": "0000000000000000000000000000000000000000",
            "type": "DELETE"
        }
    ]
}
@HussainS12
Copy link
Contributor

This is fixed in PR #932

@HussainS12 HussainS12 linked a pull request Feb 17, 2022 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants