For security reason we want to check if a Password is added to unrestricted pages
We are using following script:
def forbiddenWords = ['user/','password:','passwort:','pw:','pwd:'];
def pageId = page.id
def response = get("/wiki/rest/api/content/${pageId}")
.queryString("expand", "body.storage,space")
.asObject(Map).body
String pageBody = response.body.storage.value.toLowerCase()
forbiddenWords.each {
if (pageBody.contains(it)) {
String commentMessage = "👮️ Security Alert: word found: ${it} ❗️Do not store Password on a public page❗️"
logger.info(commentMessage)
def commentResponse = post("/wiki/rest/api/content")
.header("Content-Type", "application/json")
.body(
[
body : [
storage: [
representation: 'storage',
value : commentMessage
]
],
container: [
id : pageId,
type: 'page'
],
space : [
key: response.space.key
],
title : 'Do not store Password on a public page',
type : 'comment'
])
.asObject(Map)
logger.info("Comment response: {}", commentResponse)
The script is working except well but I need to add a check if a Confluence page is restricted or not
Any hints are highly appreciated