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

Added the AuditService #372

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Added the AuditService #372

wants to merge 8 commits into from

Conversation

ctreminiom
Copy link
Contributor

Description

Added the feature to interacts with the Jira Data Center/Server Audit Logs such as Search Audit Logs and Create new entries.

Information that is useful here:

  • The What: Added a new Service called AuditService with the methods Search and Add
  • The Why: It's useful for Jira administrators to extract security audits requested by the company SO
  • Type of change: New Feature and added documentation
  • Breaking change: NO, Backward compatible: YES
  • Related to an issue: Nop
  • Jira Version + Type: Jira 8.5.13 on-prem

Example:

Let us know how users can use or test this functionality.

Search Audit Records

See examples/audit/get/get.go

// the the records associated with the creation on the last 2 hours
	options := &jira.AuditSearchOptionsScheme{
		Filter:     "created",
		From:       time.Now().Add(time.Duration(-2) * time.Hour), // Last 2 hours
		To:         time.Time{},
		ProjectIDs: nil,
		UserIDs:    nil,
	}

	records, response, err := client.Audit.Search(context.Background(), options, 0, 50)
	if err != nil {
		if response != nil {
			log.Println("Response HTTP Response", response.StatusCode)
		}
		log.Fatal(err)
	}

	for index, record := range records.Records {

		log.Println("----------------------------------")
		log.Printf("Record #%v", index+1)
		log.Printf("Record ID: %v", record.ID)
		log.Printf("Record Created by: %v", record.Created)
		log.Printf("Record Category: %v", record.Category)
		log.Printf("Record Source IP: %v", record.RemoteAddress)
		log.Printf("Record Event: %v", record.EventSource)
		log.Println("----------------------------------")
	}

Add Audit Record

newRecord := &jira.AuditRecord{
		Summary:  "User created",
		Category: "USER_MANAGEMENT",
		ObjectItem: &jira.AuditRecordObjectItem{
			ID:       "usr",
			Name:     "user",
			TypeName: "USER",
		},
		ChangedValues: []*jira.AuditRecordChangedValue{
			{
				FieldName:   "email",
				ChangedTo:   "[email protected]",
				ChangedFrom: "[email protected]",
			},
		},

		AssociatedItems: []*jira.AuditRecordAssociatedItem{
			{
				ID:         "jira-software-users",
				Name:       "jira-software-users",
				TypeName:   "GROUP",
				ParentID:   "1",
				ParentName: "Jira Internal Directory",
			},
		},
	}

	response, err := client.Audit.Add(context.Background(), newRecord)
	if err != nil {
		if response != nil {
			log.Println("Response HTTP Response", response.StatusCode)
		}
		log.Fatal(err)
	}

	log.Println(response.StatusCode)

Checklist

@benjivesterby
Copy link
Contributor

@ctreminiom Is there a way to update this so it works with v2 and v3? That way it can support cloud? https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-audit-records/

@andygrunwald
Copy link
Owner

Hey,

I am very sorry that this pull request has been open for a long time with no final feedback or merge/decline. We work on this project in our spare time, and sometimes, other priorities take over. This is the typical open source dilemma.

However, there is news: We are kicking off v2 of this library 🚀

To provide visibility, we created the Road to v2 Milestone and calling for your feedback in #489

The development will take some time; however, I hope you can benefit from the changes.
If you seek priority development for your pull request + you like to sponsor it, please contact me.

What does this mean for my pull request?

We will work on this pull request indirectly.
We might merge it during the development or pull parts of it into the new version.
This means that during the development phase, we aim to tackle it.
Maybe in a different way like it is currently handled.
Please understand that this will take a while because we are running this in our spare time.

Final words

Thanks for using and contributing to this library.
If there is anything else you would like to tell us, let us know!

@github-actions github-actions bot added the conflicts Indicates merge conflicts label Sep 11, 2022
@ctreminiom ctreminiom closed this by deleting the head repository Oct 10, 2022
@andygrunwald
Copy link
Owner

@ctreminiom I see that this PR was closed automatically. I will re-open it, because I do think this is a valuable contribution.
I will also take care on adjusting this PR to the current codebase later on.

@andygrunwald andygrunwald reopened this Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conflicts Indicates merge conflicts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants