(tool: ToolRow)
| 211 | }; |
| 212 | |
| 213 | const policyPrefixForTool = (tool: ToolRow): string => { |
| 214 | const matchId = toolMatchId(tool); |
| 215 | const integration = String(tool.integration); |
| 216 | if (tool.connection && tool.connection.length > 0) { |
| 217 | const connection = String(tool.connection); |
| 218 | if (tool.owner) { |
| 219 | const ownerConnectionPrefix = `${integration}.${tool.owner}.${connection}`; |
| 220 | if (matchId === ownerConnectionPrefix || matchId.startsWith(`${ownerConnectionPrefix}.`)) { |
| 221 | return ownerConnectionPrefix; |
| 222 | } |
| 223 | } |
| 224 | const connectionPrefix = `${integration}.${connection}`; |
| 225 | if (matchId === connectionPrefix || matchId.startsWith(`${connectionPrefix}.`)) { |
| 226 | return connectionPrefix; |
| 227 | } |
| 228 | } |
| 229 | const name = String(tool.name); |
| 230 | if (name.length > 0 && matchId.endsWith(`.${name}`)) { |
| 231 | return matchId.slice(0, -name.length - 1); |
| 232 | } |
| 233 | const segments = matchId.split("."); |
| 234 | return segments.length > 1 ? segments.slice(0, -1).join(".") : matchId; |
| 235 | }; |
| 236 | |
| 237 | const connectionPatternForTool = (tool: ToolRow): string => `${policyPrefixForTool(tool)}.*`; |
| 238 |
no test coverage detected