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

Escape eventName in work item templates #2546

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 3 additions & 3 deletions Workbooks/WorkItems/Azure DevOps/Azure DevOps.workbook
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
"name": "bugLink",
"type": 1,
"isRequired": true,
"query": "let workItemType = \"Bug\";\r\n// Return a string of <undefined> if the input is empty\r\nlet returnundefined = (name: string) { iif(isempty(name), '<undefined>', name) };\r\n// Generate the URL to the work item creation screen, will generate all the way up to the query string.\r\n// Generate a line inside of the work item using a key and value. Bold the key.\r\nlet returnline = (key: string, value: string) { strcat(\"<p><b>\", key ,\":</b> \", url_encode(returnundefined(value)), \"</p>\") };\r\nlet urlPrefix = (workItemType:string) {strcat(\"{httpendpoint}\",\"/_workItems/create/\", workItemType, \"?\")};\r\n// Generate the default title of the work item along with its field\r\nlet witTitle = (witType:string, itemType:string, opName:string){ let itemTitle = strcat(\"[System.Title]=\", witType,\" for \", itemType, \" (\", returnundefined(opName), \")\"); iff(strlen(itemTitle) < 280, itemTitle, substring(itemTitle, 0, 280))}; \r\nlet detectionBodyOfWit = strcat(returnline(\"Rule name\", \"{ruleName:escape}\"), returnline(\"When\", \"{detectionDuration:escape}\"), returnline(\"Detection Id\", \"{detectionId:escape}\"), returnline(\"Detection Type\", \"{detectionType:escape}\"));\r\n// Generate the work item description along with its field\r\nlet witDescription = (bodyOfWit: string) { strcat(\"[Microsoft.VSTS.TCM.ReproSteps]=\", bodyOfWit) };\r\n// Append the field to the query string\r\nlet appendquerystring = (fieldToAppend:string){ strcat(\"&\", fieldToAppend)};\r\n// truncate long url and only return eventlink with queryString\r\nlet mergeUrl = (prefix: string, content:string) { let prefixLen=strlen(prefix); let contLen = strlen(content); let linkStr = appendquerystring(witDescription(returnline(\"Link\", \"{eventlink}\"))); let linklen = strlen(linkStr); let querylen = strlen(\"{queryString}\"); iff(prefixLen + contLen < 2048, strcat(prefix, content), iff(prefixLen + linklen + querylen < 2048, strcat(prefix, linkStr, \"{queryString}\"), strcat(prefix, linkStr)))};\r\nprint iff({isDetection} == 1, mergeUrl(strcat(urlPrefix(workItemType), witTitle(workItemType, \"{detectionType:escape}\", url_encode(\"{ruleName:escape}\"))), strcat(appendquerystring(witDescription(detectionBodyOfWit)), \"{queryString}\")) , mergeUrl(strcat(urlPrefix(workItemType), witTitle(workItemType, \"{itemType}\", url_encode(\"{eventName}\"))), strcat(appendquerystring(witDescription(\"{eventContent}\")), \"{queryString}\")))",
"query": "let workItemType = \"Bug\";\r\n// Return a string of <undefined> if the input is empty\r\nlet returnundefined = (name: string) { iif(isempty(name), '<undefined>', name) };\r\n// Generate the URL to the work item creation screen, will generate all the way up to the query string.\r\n// Generate a line inside of the work item using a key and value. Bold the key.\r\nlet returnline = (key: string, value: string) { strcat(\"<p><b>\", key ,\":</b> \", url_encode(returnundefined(value)), \"</p>\") };\r\nlet urlPrefix = (workItemType:string) {strcat(\"{httpendpoint}\",\"/_workItems/create/\", workItemType, \"?\")};\r\n// Generate the default title of the work item along with its field\r\nlet witTitle = (witType:string, itemType:string, opName:string){ let itemTitle = strcat(\"[System.Title]=\", witType,\" for \", itemType, \" (\", returnundefined(opName), \")\"); iff(strlen(itemTitle) < 280, itemTitle, substring(itemTitle, 0, 280))}; \r\nlet detectionBodyOfWit = strcat(returnline(\"Rule name\", \"{ruleName:escape}\"), returnline(\"When\", \"{detectionDuration:escape}\"), returnline(\"Detection Id\", \"{detectionId:escape}\"), returnline(\"Detection Type\", \"{detectionType:escape}\"));\r\n// Generate the work item description along with its field\r\nlet witDescription = (bodyOfWit: string) { strcat(\"[Microsoft.VSTS.TCM.ReproSteps]=\", bodyOfWit) };\r\n// Append the field to the query string\r\nlet appendquerystring = (fieldToAppend:string){ strcat(\"&\", fieldToAppend)};\r\n// truncate long url and only return eventlink with queryString\r\nlet mergeUrl = (prefix: string, content:string) { let prefixLen=strlen(prefix); let contLen = strlen(content); let linkStr = appendquerystring(witDescription(returnline(\"Link\", \"{eventlink}\"))); let linklen = strlen(linkStr); let querylen = strlen(\"{queryString}\"); iff(prefixLen + contLen < 2048, strcat(prefix, content), iff(prefixLen + linklen + querylen < 2048, strcat(prefix, linkStr, \"{queryString}\"), strcat(prefix, linkStr)))};\r\nprint iff({isDetection} == 1, mergeUrl(strcat(urlPrefix(workItemType), witTitle(workItemType, \"{detectionType:escape}\", url_encode(\"{ruleName:escape}\"))), strcat(appendquerystring(witDescription(detectionBodyOfWit)), \"{queryString}\")) , mergeUrl(strcat(urlPrefix(workItemType), witTitle(workItemType, \"{itemType}\", url_encode(\"{eventName:escape}\"))), strcat(appendquerystring(witDescription(\"{eventContent}\")), \"{queryString}\")))",
"isHiddenWhenLocked": true,
"timeContext": {
"durationMs": 86400000
Expand All @@ -256,7 +256,7 @@
"name": "taskLink",
"type": 1,
"isRequired": true,
"query": "let workItemType = \"Task\";\r\n// Return a string of <undefined> if the input is empty\r\nlet returnundefined = (name: string) { iif(isempty(name), '<undefined>', name) };\r\n// Generate a line inside of the work item using a key and value. Bold the key.\r\nlet returnline = (key: string, value: string) { strcat(\"<p><b>\", key ,\":</b> \", url_encode(returnundefined(value)), \"</p>\") };\r\n// Generate the URL to the work item creation screen, will generate all the way up to the query string.\r\nlet urlPrefix = (workItemType:string) {strcat(\"{httpendpoint}\",\"/_workItems/create/\", workItemType, \"?\")};\r\n// Generate the default title of the work item along with its field\r\nlet witTitle = (witType:string, itemType:string, opName:string){ let itemTitle = strcat(\"[System.Title]=\", witType,\" for \", itemType, \" (\", returnundefined(opName), \")\"); iff(strlen(itemTitle) < 280, itemTitle, substring(itemTitle, 0, 280))}; \r\nlet detectionBodyOfWit = strcat(returnline(\"Rule name\", \"{ruleName:escape}\"), returnline(\"When\", \"{detectionDuration:escape}\"), returnline(\"Detection Id\", \"{detectionId:escape}\"), returnline(\"Detection Type\", \"{detectionType:escape}\"));\r\n// Generate the work item description along with its field\r\nlet witDescription = (bodyOfWit: string) { strcat(\"[System.Description]=\", bodyOfWit)};\r\n// Append the field to the query string\r\nlet appendquerystring = (fieldToAppend:string){ strcat(\"&\", fieldToAppend)};\r\n// truncate long url and only return eventlink with queryString\r\nlet mergeUrl = (prefix: string, content:string) { let prefixLen=strlen(prefix); let contLen = strlen(content); let linkStr = appendquerystring(witDescription(returnline(\"Link\", \"{eventlink}\"))); let linklen = strlen(linkStr); let querylen = strlen(\"{queryString}\"); iff(prefixLen + contLen < 2048, strcat(prefix, content), iff(prefixLen + linklen + querylen < 2048, strcat(prefix, linkStr, \"{queryString}\"), strcat(prefix, linkStr)))};\r\nprint iff({isDetection} == 1, mergeUrl(strcat(urlPrefix(workItemType), witTitle(workItemType, \"{detectionType:escape}\", url_encode(\"{ruleName:escape}\"))), strcat(appendquerystring(witDescription(detectionBodyOfWit)), \"{queryString}\")),mergeUrl(strcat(urlPrefix(workItemType), witTitle(workItemType, \"{itemType}\", url_encode(\"{eventName}\"))), strcat(appendquerystring(witDescription(\"{eventContent}\")), \"{queryString}\")))",
"query": "let workItemType = \"Task\";\r\n// Return a string of <undefined> if the input is empty\r\nlet returnundefined = (name: string) { iif(isempty(name), '<undefined>', name) };\r\n// Generate a line inside of the work item using a key and value. Bold the key.\r\nlet returnline = (key: string, value: string) { strcat(\"<p><b>\", key ,\":</b> \", url_encode(returnundefined(value)), \"</p>\") };\r\n// Generate the URL to the work item creation screen, will generate all the way up to the query string.\r\nlet urlPrefix = (workItemType:string) {strcat(\"{httpendpoint}\",\"/_workItems/create/\", workItemType, \"?\")};\r\n// Generate the default title of the work item along with its field\r\nlet witTitle = (witType:string, itemType:string, opName:string){ let itemTitle = strcat(\"[System.Title]=\", witType,\" for \", itemType, \" (\", returnundefined(opName), \")\"); iff(strlen(itemTitle) < 280, itemTitle, substring(itemTitle, 0, 280))}; \r\nlet detectionBodyOfWit = strcat(returnline(\"Rule name\", \"{ruleName:escape}\"), returnline(\"When\", \"{detectionDuration:escape}\"), returnline(\"Detection Id\", \"{detectionId:escape}\"), returnline(\"Detection Type\", \"{detectionType:escape}\"));\r\n// Generate the work item description along with its field\r\nlet witDescription = (bodyOfWit: string) { strcat(\"[System.Description]=\", bodyOfWit)};\r\n// Append the field to the query string\r\nlet appendquerystring = (fieldToAppend:string){ strcat(\"&\", fieldToAppend)};\r\n// truncate long url and only return eventlink with queryString\r\nlet mergeUrl = (prefix: string, content:string) { let prefixLen=strlen(prefix); let contLen = strlen(content); let linkStr = appendquerystring(witDescription(returnline(\"Link\", \"{eventlink}\"))); let linklen = strlen(linkStr); let querylen = strlen(\"{queryString}\"); iff(prefixLen + contLen < 2048, strcat(prefix, content), iff(prefixLen + linklen + querylen < 2048, strcat(prefix, linkStr, \"{queryString}\"), strcat(prefix, linkStr)))};\r\nprint iff({isDetection} == 1, mergeUrl(strcat(urlPrefix(workItemType), witTitle(workItemType, \"{detectionType:escape}\", url_encode(\"{ruleName:escape}\"))), strcat(appendquerystring(witDescription(detectionBodyOfWit)), \"{queryString}\")),mergeUrl(strcat(urlPrefix(workItemType), witTitle(workItemType, \"{itemType}\", url_encode(\"{eventName:escape}\"))), strcat(appendquerystring(witDescription(\"{eventContent}\")), \"{queryString}\")))",
"isHiddenWhenLocked": true,
"timeContext": {
"durationMs": 86400000
Expand All @@ -274,7 +274,7 @@
{
"type": 1,
"content": {
"json": "### Create Work Item for {eventName}\r\n"
"json": "### Create Work Item for {eventName:escape}\r\n"
},
"name": "text - eventTitle"
},
Expand Down
4 changes: 2 additions & 2 deletions Workbooks/WorkItems/GitHub/GitHub.workbook
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
"version": "KqlParameterItem/1.0",
"name": "issueLink",
"type": 1,
"query": "let workItemType = \"Issue\";\r\n\r\n//*\r\n//* These helper methods will generate the correctly formatted output for the work item creation. You can edit these to suit your needs.\r\n//*\r\n// Return a string of <undefined> if the input is empty\r\nlet returnundefined = (name: string) { iif(isempty(name), '<undefined>', name) };\r\n// Generate the URL to the work item creation screen, will generate all the way up to the query string.\r\n// Generate a line inside of the work item using a key and value. Bold the key.\r\nlet returnline = (key: string, value: string) { strcat(\"**\", key ,\":** \", url_encode(returnundefined(value)), url_encode(\"\\r\\n\\r\\n\")) };\r\nlet urlPrefix = (workItemType:string) {strcat(\"{httpendpoint}\",\"/issues/new?\")};\r\nlet witTitle = (witType:string, itemType:string, opName:string){ let itemTitle = strcat(\"title=\", witType,\" for \", itemType, \" (\", returnundefined(opName), \")\"); iff(strlen(itemTitle) < 280, itemTitle, substring(itemTitle, 0, 280))}; \r\nlet detectionBodyOfWit = strcat(returnline(\"Rule name\", \"{ruleName:escape}\"), returnline(\"When\", \"{detectionDuration:escape}\"), returnline(\"Detection Id\", \"{detectionId:escape}\"), returnline(\"Detection Type\", \"{detectionType:escape}\"));\r\n// Generate the work item description along with its field\r\nlet witDescription = (bodyOfWit: string) { strcat(\"body=\", bodyOfWit) };\r\n// Append the field to the query string\r\nlet appendquerystring = (fieldToAppend:string){ strcat(\"&\", fieldToAppend)}; \r\n// truncate long url and only return eventlink with queryString\r\nlet mergeUrl = (prefix: string, content:string) { let prefixLen=strlen(prefix); let contLen = strlen(content); let linkStr = appendquerystring(witDescription(returnline(\"Link\", \"{eventlink}\"))); let linklen = strlen(linkStr); let querylen = strlen(\"{queryString}\"); iff(prefixLen + contLen < 2048, strcat(prefix, content), iff(prefixLen + linklen + querylen < 2048, strcat(prefix, linkStr, \"{queryString}\"), strcat(prefix, linkStr)))};\r\nprint iff({isDetection} == 1, mergeUrl(strcat(urlPrefix(workItemType), witTitle(workItemType, \"{detectionType:escape}\", url_encode(\"{ruleName:escape}\"))), strcat(appendquerystring(witDescription(detectionBodyOfWit)), \"{queryString}\")), mergeUrl(strcat(urlPrefix(workItemType), witTitle(workItemType, \"{itemType}\", url_encode(\"{eventName}\"))), strcat(appendquerystring(witDescription(\"{eventContent}\")), \"{queryString}\")))",
"query": "let workItemType = \"Issue\";\r\n\r\n//*\r\n//* These helper methods will generate the correctly formatted output for the work item creation. You can edit these to suit your needs.\r\n//*\r\n// Return a string of <undefined> if the input is empty\r\nlet returnundefined = (name: string) { iif(isempty(name), '<undefined>', name) };\r\n// Generate the URL to the work item creation screen, will generate all the way up to the query string.\r\n// Generate a line inside of the work item using a key and value. Bold the key.\r\nlet returnline = (key: string, value: string) { strcat(\"**\", key ,\":** \", url_encode(returnundefined(value)), url_encode(\"\\r\\n\\r\\n\")) };\r\nlet urlPrefix = (workItemType:string) {strcat(\"{httpendpoint}\",\"/issues/new?\")};\r\nlet witTitle = (witType:string, itemType:string, opName:string){ let itemTitle = strcat(\"title=\", witType,\" for \", itemType, \" (\", returnundefined(opName), \")\"); iff(strlen(itemTitle) < 280, itemTitle, substring(itemTitle, 0, 280))}; \r\nlet detectionBodyOfWit = strcat(returnline(\"Rule name\", \"{ruleName:escape}\"), returnline(\"When\", \"{detectionDuration:escape}\"), returnline(\"Detection Id\", \"{detectionId:escape}\"), returnline(\"Detection Type\", \"{detectionType:escape}\"));\r\n// Generate the work item description along with its field\r\nlet witDescription = (bodyOfWit: string) { strcat(\"body=\", bodyOfWit) };\r\n// Append the field to the query string\r\nlet appendquerystring = (fieldToAppend:string){ strcat(\"&\", fieldToAppend)}; \r\n// truncate long url and only return eventlink with queryString\r\nlet mergeUrl = (prefix: string, content:string) { let prefixLen=strlen(prefix); let contLen = strlen(content); let linkStr = appendquerystring(witDescription(returnline(\"Link\", \"{eventlink}\"))); let linklen = strlen(linkStr); let querylen = strlen(\"{queryString}\"); iff(prefixLen + contLen < 2048, strcat(prefix, content), iff(prefixLen + linklen + querylen < 2048, strcat(prefix, linkStr, \"{queryString}\"), strcat(prefix, linkStr)))};\r\nprint iff({isDetection} == 1, mergeUrl(strcat(urlPrefix(workItemType), witTitle(workItemType, \"{detectionType:escape}\", url_encode(\"{ruleName:escape}\"))), strcat(appendquerystring(witDescription(detectionBodyOfWit)), \"{queryString}\")), mergeUrl(strcat(urlPrefix(workItemType), witTitle(workItemType, \"{itemType}\", url_encode(\"{eventName:escape}\"))), strcat(appendquerystring(witDescription(\"{eventContent}\")), \"{queryString}\")))",
"isHiddenWhenLocked": true,
"timeContext": {
"durationMs": 86400000
Expand All @@ -258,7 +258,7 @@
{
"type": 1,
"content": {
"json": "### Create Work Item for {eventName}"
"json": "### Create Work Item for {eventName:escape}"
},
"name": "text - eventTitle"
},
Expand Down
Loading