Confluence Scanner Plugin
Relevant source files
The following files were used as context for generating this wiki page:
The Confluence Scanner Plugin is a specialized module within the 2ms (Too Many Secrets) tool designed to identify sensitive information, such as secrets and credentials, stored within Confluence instances. It operates by crawling spaces and pages via the Confluence REST API, converting page content into a standardized format for the 2ms scanning engine.
The plugin supports both authenticated and anonymous scanning. When credentials are provided, it can access private spaces and optionally iterate through page history to detect secrets that may have been removed in newer versions but persist in the historical record.
Sources: plugins/confluence.go:42-51, README.md:214-230
Architecture and Components
The plugin is built around the ConfluencePlugin struct, which implements the IPlugin interface defined in the project's plugin architecture. It utilizes a dedicated IConfluenceClient to handle HTTP interactions with the Atlassian REST API.
Core Data Structures
| Structure | Purpose | Source File |
|---|---|---|
ConfluencePlugin | Main plugin controller handling command definition and scan orchestration. | plugins/confluence.go:30-40 |
confluenceClient | Implementation of IConfluenceClient that manages HTTP requests and authentication. | plugins/confluence.go:193-197 |
ConfluencePageContent | Model for the JSON response containing page body storage and history metadata. | plugins/confluence.go:242-257 |
ISourceItem | Interface for items passed to the engine, implemented by the internal item struct. | plugins/plugins.go:11-25 |
Component Relationship
The following diagram illustrates the relationship between the plugin, its client, and the core 2ms engine.
Data Flow and Execution Logic
The plugin execution follows a hierarchical discovery process: Instance -> Spaces -> Pages -> Versions.
- Initialization: The plugin parses the Confluence URL and validates credentials. If no username or token is provided, it logs a warning and proceeds with anonymous access.
- Space Discovery: It fetches all available spaces (or a filtered list if
--spacesis provided). - Page Iteration: For each space, it retrieves all pages using pagination (default window of 25 items).
- Content Extraction: For each page, the latest version's content is fetched. If the
Historyflag is enabled, the plugin recursively fetches previous versions until no more exist. - Standardization: Content is wrapped in an
itemstruct and sent to theitemsChanfor the scanning engine.
Scan Sequence Diagram
This diagram shows the sequence of API calls and internal processing during a typical scan.
Configuration and CLI Arguments
The plugin exposes several flags via the cobra command-line interface to control scan behavior.
| Flag | Argument | Default | Description |
|---|---|---|---|
--url | argUrl | N/A | The base URL of the Confluence wiki (e.g., https://site.atlassian.net/wiki). |
--spaces | argSpaces | [] (All) | String slice of space keys or names to include in the scan. |
--username | argUsername | "" | User email or username for Basic Auth. |
--token | argToken | "" | API token for authentication. |
--history | argHistory | false | Boolean flag to trigger scanning of all historical versions of a page. |
Sources: plugins/confluence.go:18-28, plugins/confluence.go:68-73
Implementation Details
Pagination Logic
The plugin implements automatic pagination for both spaces and pages to overcome REST API limits. It continues requesting items as long as the response size matches the confluenceDefaultWindow (25).
// Example pagination logic for spaces
for actualSize == confluenceDefaultWindow {
moreSpaces, err := p.client.getSpacesRequest(totalSpaces.Size)
if err != nil {
return nil, err
}
totalSpaces.Results = append(totalSpaces.Results, moreSpaces.Results...)
totalSpaces.Size += moreSpaces.Size
actualSize = moreSpaces.Size
}
Sources: plugins/confluence.go:149-160
Rate Limiting and Concurrency
The plugin uses a buffered channel p.Limit to control the number of concurrent goroutines performing page scans. The confluenceMaxRequests constant is set to 500 to prevent overwhelming the server or hitting API rate limits too quickly.
Sources: plugins/confluence.go:27, plugins/confluence.go:84-86, plugins/confluence.go:107-113
Content Conversion
Page content is converted to the ISourceItem interface using the convertPageToItem function. The ID for each item is generated using the pattern confluence-{spaceKey}-{pageID}, ensuring uniqueness across the scan.
Sources: plugins/confluence.go:136-142, plugins/confluence_test.go:182-186
Summary
The Confluence Scanner Plugin provides a robust mechanism for deep-scanning Atlassian Confluence environments. By integrating with the project's core engine, it allows organizations to identify hardcoded passwords, API keys, and other secrets hidden in wiki pages. Its primary strengths include support for paginated discovery and the ability to traverse historical page versions, which is critical for finding secrets that were "deleted" but remain in the version history.