Skip to content

Commit dc20e33

Browse files
authored
docs: add Security & Quality Conventions to copilot-instructions.md (#22)
* docs: add Security & Quality Conventions to copilot-instructions.md * docs: fix grammar (install and upgrade)
1 parent c59b114 commit dc20e33

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎.github/copilot-instructions.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,28 @@ Document all changes in `CHANGELOG.md`; use descriptive commit messages referenc
147147
- [Cacti Documentation](https://www.github.com/Cacti/documentation)
148148
- `README.md` for feature descriptions
149149
- `CHANGELOG.md` for version history
150+
151+
## Security & Quality Conventions
152+
153+
These conventions apply across the Cacti plugin fleet and should be followed whenever touching
154+
existing code or adding new code, not just in dedicated cleanup passes:
155+
156+
- **No hardcoded third-party hosts.** Never hardcode a third-party IP address, hostname, or URL
157+
in plugin code (even for tooling/download helpers). Expose it as a plugin setting instead, with
158+
secure-by-default values (e.g. an SSL-verification setting that defaults to verify-on).
159+
- **Prepared statements over `db_qstr()`.** Build dynamic `WHERE` clauses using the
160+
`$sql_where`/`$sql_params` prepared-statement pattern, not string concatenation via `db_qstr()`.
161+
- **Use `html_escape_request_var()`.** Prefer it over the `html_escape(get_request_var(...))` call
162+
chain.
163+
- **Harden `unserialize()`.** Always pass `['allow_classes' => false]` as the second argument.
164+
- **i18n text domain.** Every `__()`/`__esc()` call must include this plugin's text domain as the
165+
final argument, except when deliberately comparing against a literal, untranslated Cacti-core
166+
label.
167+
- **Plugin table-creation API.** Use `api_plugin_db_table_create()`/`api_plugin_db_add_column()`
168+
(from Cacti core's `lib/plugins.php`) instead of raw `CREATE TABLE`/`ALTER TABLE ... ADD COLUMN`.
169+
Both are idempotent (safe no-ops when already applied), so the same call can run unconditionally
170+
from both the install and upgrade paths.
171+
- **PHPDoc shape.** Every function gets a PHPDoc block: a one-line description, a blank comment
172+
line, `@param` lines, a blank comment line, then `@return`. Infer parameter/return types from
173+
actual usage; don't change the function's real type-hints in the same pass (let static analysis
174+
flag mismatches separately). Skip vendored third-party library files.

0 commit comments

Comments
 (0)