feat: SDElements integration — projects, tasks, threats, users#13
feat: SDElements integration — projects, tasks, threats, users#13
Conversation
Adds `pncli sde` command group with 8 read-only subcommands against the SDElements REST API v2. Supports both cloud (*.sdelements.com) and on-premise deployments via configurable baseUrl. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new SDElements service integration to pncli, following the existing “service client + commands + config” pattern used for Jira/Sonar/etc., enabling read-only querying of SDElements API v2 resources from the CLI.
Changes:
- Introduces
pncli sdecommand group with subcommands for server info, current user, users, projects, tasks (countermeasures), and threats. - Adds SDElements configuration support (config init/test, env vars, resolved config + masking) and HTTP client support with
Authorization: Token …. - Defines TypeScript response types for SDElements API v2.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/types/sde.ts | Adds SDElements API v2 response type definitions (server info, users, projects, tasks, threats, pagination). |
| src/types/config.ts | Extends config schema with sde config + defaults.sde. |
| src/services/sde/commands.ts | Registers pncli sde subcommands and wires them to the SDE client, including default project resolution. |
| src/services/sde/client.ts | Implements SDElements REST API v2 client methods and pagination helpers. |
| src/services/config/commands.ts | Extends config init prompts and config test connectivity checks for SDElements. |
| src/lib/http.ts | Adds http.sde() and http.sdePaginate() plus Token auth header support. |
| src/lib/config.ts | Adds env var support and resolved config masking for SDElements. |
| src/cli.ts | Registers the new SDE command group in the CLI. |
| copilot-instructions.md | Documents the new pncli sde commands and flags. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const id = parseInt(project, 10); | ||
| if (isNaN(id)) throw new PncliError(`Invalid project ID: ${project}. SDElements project IDs are numeric.`); |
There was a problem hiding this comment.
resolveProject() uses parseInt(project, 10), which will accept partially-numeric strings like "42abc" (parses to 42). Since the CLI help/error says project IDs are numeric, this should be a stricter validation (e.g., /^\d+$/ check before parsing, and optionally enforce id > 0).
| const id = parseInt(project, 10); | |
| if (isNaN(id)) throw new PncliError(`Invalid project ID: ${project}. SDElements project IDs are numeric.`); | |
| if (!/^\d+$/.test(project)) throw new PncliError(`Invalid project ID: ${project}. SDElements project IDs are numeric.`); | |
| const id = parseInt(project, 10); | |
| if (id <= 0) throw new PncliError(`Invalid project ID: ${project}. SDElements project IDs are numeric.`); |
…, README - Extract projectParams/taskParams/threatParams/userParams builders in SdeClient to eliminate duplicated params objects across list/listAll pairs - Add parsePage() helper in commands.ts with NaN + range check on all --page and --page-size flags - Add validateActive() helper to enforce allowed values at command layer (users: true|false, projects: true|false|all) - Add SDE to README services table and env var docs; add npm badge Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tructions - Config init prompt now shows cloud vs on-prem URL format separately - copilot-instructions.md: update tagline to include SDElements, add setup note with cloud URL format, token generation path, and project ID tip - TLS comment in cli.ts left as-is (global concern, not SDE-specific) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reject partially-numeric strings like "42abc" by testing against /^\d+$/ before parseInt. Also enforce id > 0 to catch zero inputs. Addresses copilot-pull-request-reviewer inline comment on PR #13. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
pncli sdecommand group with 8 read-only subcommands against the SDElements REST API v2*.sdelements.com) and on-premise deployments via configurablebaseUrlCommands
sde server-infosde whoamisde userssde projectssde projectsde taskssde tasksde threatsAll list commands support
--allfor full pagination, or--page/--page-sizefor manual control.Configuration
{ "sde": { "baseUrl": "https://your-org.sdelements.com", "token": "<api-token>" }, "defaults": { "sde": { "project": "42" } } }Env vars:
PNCLI_SDE_BASE_URL,PNCLI_SDE_TOKEN. Default project also settable per-repo via.pncli.json.Notes
Authorization: Token <token>(SDElements format) rather thanBearerpncli config testusesGET /api/v2/users/me/(avoids super-user requirement of/server-info/)resolveProject()parses and validates themTest plan
npm run build— clean TypeScript compilationpncli sde --help— all 8 subcommands listedpncli config init— SDElements prompts appearpncli sde whoami --dry-run— request usesTokenauth header, correct URLpncli config test— SDE connectivity result appearspncli sde whoami,pncli sde projects --all,pncli sde tasks --project <id>🤖 Generated with Claude Code