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.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:-
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.
2. Next, in this screenshot I am executing the script
3. Finally, in the next screenshots, you can see that the usernames and passwords have been removed from the issue descriptions.
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It worked Ram @Ram Kumar Aravindakshan _Adaptavist_. Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.