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

✨ Add project key, creator and issue type #4623

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions providers/atlassian/resources/atlassian.lr
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,18 @@ atlassian.jira.issue @defaults("id createdAt") {
id string
// Project
project string
// Project key
projectKey string
// Status
status string
// Description
description string
// Issue create time in UTC
createdAt time
// Issue creator
creator atlassian.jira.user
// Issue type name
typeName string
}

// Jira server info
Expand Down
36 changes: 36 additions & 0 deletions providers/atlassian/resources/atlassian.lr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions providers/atlassian/resources/atlassian.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,13 @@ resources:
atlassian.jira.issue:
fields:
createdAt: {}
creator: {}
description: {}
id: {}
project: {}
projectKey: {}
status: {}
typeName: {}
min_mondoo_version: 9.0.0
atlassian.jira.project:
fields:
Expand Down
17 changes: 16 additions & 1 deletion providers/atlassian/resources/atlassian_jira.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (a *mqlAtlassianJira) issues() ([]interface{}, error) {
jira := conn.Client()
validate := ""
jql := "order by created DESC"
fields := []string{"created", "status", "project", "description"}
fields := []string{"created", "creator", "status", "project", "description", "issuetype"}
expands := []string{"changelog", "renderedFields", "names", "schema", "transitions", "operations", "editmeta"}

res := []interface{}{}
Expand All @@ -226,13 +226,28 @@ func (a *mqlAtlassianJira) issues() ([]interface{}, error) {
return nil, err
}

creator := issue.Fields.Creator
mqlAtlassianJiraUser, err := CreateResource(a.MqlRuntime, "atlassian.jira.user",
map[string]*llx.RawData{
"id": llx.StringData(creator.AccountID),
"name": llx.StringData(creator.DisplayName),
"type": llx.StringData(creator.AccountType),
"picture": llx.StringData(creator.AvatarUrls.One6X16),
})
if err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've no clue about Jira, so perhaps a dump question:
Could someone be permitted to view the issues but not the users?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, those are public data which you can see if you see the issue (tiny picture below, name and so on)

}

mqlAtlassianJiraIssue, err := CreateResource(a.MqlRuntime, "atlassian.jira.issue",
map[string]*llx.RawData{
"id": llx.StringData(issue.ID),
"project": llx.StringData(issue.Fields.Project.Name),
"projectKey": llx.StringData(issue.Fields.Project.Key),
"status": llx.StringData(issue.Fields.Status.Name),
"description": llx.StringData(issue.Fields.Description),
"createdAt": llx.TimeData(created.UTC()),
"creator": llx.AnyData(mqlAtlassianJiraUser),
"typeName": llx.StringData(issue.Fields.IssueType.Name),
})
if err != nil {
return nil, err
Expand Down
Loading