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

feat: control permissions and cli #258

Merged
merged 2 commits into from
Dec 2, 2024
Merged

Conversation

golanglemonade
Copy link
Member

@golanglemonade golanglemonade commented Dec 1, 2024

  • Adds organization owner to control with permissions given by either user that created the control, inherited permissions from associated program, or permission from a group (editor, viewer, blocked). This aligns with the other recently updated objects (narratives, risks, etc)
  • There is a TODO on the policies to add additional permissions for create of a control; this will be addressed with similar objects on a follow-up PR to allow access to create via groups and not just restricted to organization admins
  • Adds basic cli commands for controls
  • Speeds up graph tests slightly by not recreating the client each time, only the test data

Create control with a program:

go run cmd/cli/main.go control create -n sc -f sc -p 01JDWZ2SM9FSN5ZNFJGKDXAJXK 
  ID                          NAME  DESCRIPTION  STATUS  CONTROLTYPE  VERSION  CONTROLNUMBER  FAMILY  CLASS  SOURCE  MAPPEDFRAMEWORKS  SATISFIES  PROGRAMS  
  01JE1WQ6RYSS474RYD84T04GF3  sc                                                              sc                                                  [mitb2]   

User who created the controls can see/edit the control(s):

(go run cmd/cli/main.go control get  -z json         
{
  "controls": {
    "edges": [
      {
        "node": {
          "class": "",
          "controlNumber": "",
          "controlType": "",
          "createdAt": "2024-12-01T12:56:19.111118-07:00",
          "createdBy": "01JDWZ2E3EMVVXAFZVTXJFNSY2",
          "description": "",
          "family": "sc",
          "id": "01JE1WQ6RYSS474RYD84T04GF3",
          "mappedFrameworks": "",
          "name": "sc",
          "programs": [
            {
              "id": "01JDWZ2SM9FSN5ZNFJGKDXAJXK",
              "name": "mitb2"
            }
          ],
          "satisfies": "",
          "source": "",
          "status": "",
          "updatedAt": "2024-12-01T12:56:19.102809-07:00",
          "updatedBy": "01JDWZ2E3EMVVXAFZVTXJFNSY2",
          "version": ""
        }
      },
      {
        "node": {
          "class": "",
          "controlNumber": "",
          "controlType": "",
          "createdAt": "2024-12-01T12:56:59.592006-07:00",
          "createdBy": "01JDWZ2E3EMVVXAFZVTXJFNSY2",
          "description": "",
          "family": "sc",
          "id": "01JE1WREA36VE5HTZ6CB7EY9QS",
          "mappedFrameworks": "",
          "name": "sc2",
          "satisfies": "",
          "source": "",
          "status": "",
          "updatedAt": "2024-12-01T12:56:59.587305-07:00",
          "updatedBy": "01JDWZ2E3EMVVXAFZVTXJFNSY2",
          "version": ""
        }
      }
    ]
  }
}

User that only has permissions via the program can only see the one control:

task cli:login:another                     
task: [cli:login:creds] go run main.go login -u funk@theopenlane.io

Authentication Successful!
auth tokens successfully stored in keychain
(⎈ |default:default)➜  core git:(feat-control-perms) go run cmd/cli/main.go control get  -z json
{
  "controls": {
    "edges": [
      {
        "node": {
          "class": "",
          "controlNumber": "",
          "controlType": "",
          "createdAt": "2024-12-01T12:56:19.111118-07:00",
          "createdBy": "01JDWZ2E3EMVVXAFZVTXJFNSY2",
          "description": "",
          "family": "sc",
          "id": "01JE1WQ6RYSS474RYD84T04GF3",
          "mappedFrameworks": "",
          "name": "sc",
          "programs": [
            {
              "id": "01JDWZ2SM9FSN5ZNFJGKDXAJXK",
              "name": "mitb2"
            }
          ],
          "satisfies": "",
          "source": "",
          "status": "",
          "updatedAt": "2024-12-01T12:56:19.102809-07:00",
          "updatedBy": "01JDWZ2E3EMVVXAFZVTXJFNSY2",
          "version": ""
        }
      }
    ]
  }
}

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>
Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>
Copy link

sonarqubecloud bot commented Dec 2, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
13.6% Coverage on New Code (required ≥ 20%)

See analysis details on SonarQube Cloud

@golanglemonade golanglemonade merged commit 285c96d into main Dec 2, 2024
16 of 17 checks passed
@golanglemonade golanglemonade deleted the feat-control-perms branch December 2, 2024 17:27
matoszz pushed a commit that referenced this pull request Dec 6, 2024
* feat: control permissions and cli

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* fix: don't recreate clients on every test, only test data

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

---------

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants