GetToolScopeMapFromInventory builds a tool scope map from an inventory. This extracts scope information from ServerTool.RequiredScopes and ServerTool.AcceptedScopes.
(inv *inventory.Inventory)
| 50 | // GetToolScopeMapFromInventory builds a tool scope map from an inventory. |
| 51 | // This extracts scope information from ServerTool.RequiredScopes and ServerTool.AcceptedScopes. |
| 52 | func GetToolScopeMapFromInventory(inv *inventory.Inventory) ToolScopeMap { |
| 53 | result := make(ToolScopeMap) |
| 54 | |
| 55 | // Get all tools from the inventory (both enabled and disabled) |
| 56 | // We need all tools for scope checking purposes |
| 57 | allTools := inv.AllTools() |
| 58 | for i := range allTools { |
| 59 | tool := &allTools[i] |
| 60 | if len(tool.RequiredScopes) > 0 || len(tool.AcceptedScopes) > 0 { |
| 61 | result[tool.Tool.Name] = &ToolScopeInfo{ |
| 62 | RequiredScopes: tool.RequiredScopes, |
| 63 | AcceptedScopes: tool.AcceptedScopes, |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | return result |
| 69 | } |
| 70 | |
| 71 | // HasAcceptedScope checks if any of the provided user scopes satisfy the tool's requirements. |
| 72 | func (t *ToolScopeInfo) HasAcceptedScope(userScopes ...string) bool { |
no test coverage detected