Paligo Scanner Plugin
Relevant source files
The following files were used as context for generating this wiki page:
The Paligo Scanner Plugin is a specialized module within the 2ms (Too Many Secrets) tool designed to identify sensitive information, such as authentication keys and passwords, stored within the Paligo Content Management System (CMS). As part of the broader 2ms ecosystem, it integrates with a centralized scanning engine to apply detection rules against content retrieved from Paligo instances.
The plugin functions by recursively traversing Paligo folder structures via the Paligo API, identifying components (documents), and extracting their content for analysis. It supports various authentication methods and provides granular control over the scan scope through folder-specific targeting.
Sources: README.md:14-19, plugins/paligo.go:61-63
Architecture and Data Flow
The Paligo plugin follows a provider-consumer pattern where it acts as a source provider for the 2ms detection engine. It implements the IPlugin interface, allowing it to be registered alongside other plugins like Git or Confluence.
High-Level Scan Flow
The scan process begins with authentication and a root-level discovery of folders. The plugin then enters a processing loop where it identifies child folders and documents. Each document's content is wrapped into a standardized ISourceItem and sent to a shared channel for the engine to process.
The diagram shows the recursive traversal of the Paligo hierarchy and the hand-off to the detection engine.
Sources: plugins/paligo.go:103-125, cmd/main.go:48-55
Configuration and Command Line Interface
The plugin is invoked through the paligo subcommand. It requires specific flags for instance identification and authentication.
Command Flags
| Flag | Description | Requirement |
|---|---|---|
--instance | The name of the Paligo instance to scan. | Required |
--username | Paligo username for Basic Auth. | Optional (Pairs with --token) |
--token | API token for authentication. | Optional (Pairs with --username) |
--auth | Base64 encoded username:password string. | Optional (Exclusive to user/token) |
--folder | Specific Folder ID to limit scan scope. | Optional |
Sources: plugins/paligo.go:21-33, README.md:204-211
Authentication Logic
The plugin supports two primary authentication paths:
- Standard Basic Auth: Created from a provided username and token.
- Encoded Header: A direct Base64 string provided via the
--authflag.
Sources: plugins/paligo.go:44-51, plugins/paligo.go:81-88
Technical Implementation
Data Structures
The plugin defines several internal structures to map Paligo API responses to Go objects.
type PaligoItem struct {
ID int `json:"id"`
Name string `json:"name"`
UUID string `json:"uuid"`
Type string `json:"type"`
}
type Document struct {
PaligoItem
Content string `json:"content"`
Languages []string `json:"languages"`
}
Sources: plugins/paligo.go:167-172, plugins/paligo.go:211-215
Rate Limiting
To prevent API abuse and handle service constraints, the plugin implements a dual-limiter strategy using the golang.org/x/time/rate package. It manages separate limits for folder discovery and document retrieval.
- Folder Show Limit: 50 requests per interval.
- Document Show Limit: 50 requests per interval.
- Retry Logic: If a
429 Too Many Requestsstatus is encountered, the plugin parses theRetry-Afterheader and pauses execution.
Sources: plugins/paligo.go:156-165, plugins/paligo.go:230-246
Component Handling
When a "component" (document) is identified, the plugin constructs a unique ID and a source URL that allows developers to link directly back to the Paligo editor.
Sources: plugins/paligo.go:142-154
Integration with Detection Engine
Once the Paligo content is sent to the Items channel, the Engine module takes over. It iterates through the content using the rules defined in engine/rules/rules.go. For Paligo, the engine specifically looks for secrets that might be embedded in technical documentation, such as API keys or hardcoded credentials.
Key engine interactions include:
- Detection: Running regex-based rules against document fragments.
- Scoring: Assigning CVSS scores based on the
CategoryContentManagementSystemrisk profile. - Reporting: Aggregating findings into JSON, YAML, or SARIF formats.
Sources: engine/engine.go:85-110, engine/rules/rules.go:48-50, lib/reporting/report.go:59-69
Summary
The Paligo Scanner Plugin enables 2ms to extend its secret detection capabilities to cloud-based technical documentation. By implementing recursive folder traversal, robust rate limiting, and direct integration with the core detection engine, it provides an automated way to ensure that sensitive data is not inadvertently published in Paligo-managed content.
Sources: plugins/paligo.go:70-75, README.md:14-19