Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Sanitizing data inside of Jira

Lakshmi CH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 2, 2024

Hi Team,

We found a project that has a number of tickets that include credentials (usernames/passwords) and want to get them cleaned up. If we just edit them, I think they will still be visible in the ticket history. I'm wondering if there is a way to clean up the description and not just delete the tickets.

2 answers

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
January 2, 2024

Hi @Lakshmi CH

It is possible to do, but could you provide a little bit more information, i.e. do you only intend to remove the username and password and preserve the remainder of the description field?

If yes, are all the issues that are impacted having a similar format for the description field?

I am looking forward to your feedback and clarification.

Thank you and Kind regards,

Ram

Lakshmi CH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 3, 2024

Hi @Ram Kumar Aravindakshan _Adaptavist_ ,

 Yes, We want to delete only the usernames and passwords while preserving the rest of the description.

The format means, wording varies between descriptions. Some tickets have less description, while others have different wording.

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
January 4, 2024

Hi @Lakshmi CH

For your requirement, you can try something like below on the ScriptRunner console:-

import com.adaptavist.hapi.jira.issues.Issues
import com.adaptavist.hapi.jira.projects.Projects
import com.atlassian.jira.component.ComponentAccessor

def project = Projects.getByKey('MOCK')
def issueManager = ComponentAccessor.issueManager

def builder = new StringBuilder()

final def username = 'Username'
final def password = 'Password'

issueManager.getIssueIdsForProject(project.id).each { id ->
def issue = Issues.getByKey(issueManager.getIssueObject(id).key)

if (builder.size() > 0) {
builder.setLength(0)
}

def description = issue.description

if(description.contains(username) && description.contains(password)) {
def lines = description.split(System.getProperty('line.separator'))

lines.each { line ->
if (line.startsWith(username) || line.startsWith(password)) {
return
} else {
builder.append(line).append(System.getProperty('line.separator'))
}
}
}

issue.update {
setDescription(builder.toString())
}
}

Please note that the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.

Below is a screenshot of the ScriptRunner Console configuration:-

configuration.png

 

Below are a couple of test screenshots for your reference:-

1. The screenshots below display all the issues where their description contains the username and password values before the script has been executed.

test1.pngtest2.pngtest3.pngtest4.png

2. Next, in this screenshot I am executing the script

test5.png

3. Finally, in the next screenshots, you can see that the usernames and passwords have been removed from the issue descriptions.

output1.pngoutput2.pngoutput3.pngoutput4.png

 

I hope this helps to solve your question. :-)

Thank you and Kind regards,

Ram

Lakshmi CH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 8, 2024

It worked Ram @Ram Kumar Aravindakshan _Adaptavist_. Thank you!

1 vote
Rebekka Heilmann _viadee_
Community Champion
January 2, 2024

If you edit the issue you will always have the old info in the history.

You could change the description, clone the issue and then delete the old one. That should get rid of all historic changes and data.

Suggest an answer

Log in or Sign up to answer