Skip to content

Commit a9d7042

Browse files
committed
Add Snyk rules and improve audit command
Add Snyk security guidance and editor settings, update ignore list and README formatting, and make audit command more robust. - Added .cursor/rules/snyk_rules.mdc with Snyk code-scan guidance for new code. - Added .vscode/settings.json to enable Snyk auto-select organization. - Updated .gitignore to include Snyk rules and coverage-html directory. - Fixed README table-of-contents list formatting and a minor wording change. - Updated src/Commands/WardenAuditCommand.php to: detect and use output->isSilent() when available (Symfony Console 7.2+/Laravel 11+), fall back to using !isVerbose() for older versions, and handle empty/null audit service names by falling back to "Unknown service". These changes improve compatibility and error messaging.
1 parent 0065fd8 commit a9d7042

5 files changed

Lines changed: 47 additions & 19 deletions

File tree

.cursor/rules/snyk_rules.mdc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
alwaysApply: true
3+
always_on: true
4+
trigger: always_on
5+
applyTo: "**"
6+
description: Snyk Security At Inception
7+
---
8+
9+
# Project security best practices
10+
11+
- Always run snyk_code_scan tool for new first party code that is generated in a Snyk-supported language.
12+
- If any security issues are found based on newly introduced or modified code or dependencies, attempt to fix the issues using the results context from Snyk.
13+
- Rescan the code after fixing the issues to ensure that the issues were fixed and that there are no newly introduced issues.
14+
- Repeat this process until no new issues are found.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.phpunit.cache
22
/vendor
3-
.idea
3+
.idea
4+
# Snyk Security Extension - AI Rules (auto-generated)
5+
.windsurf/rules/snyk_rules.md
6+
/coverage-html

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"snyk.advanced.autoSelectOrganization": true
3+
}

readme.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ Perfect for continuous security monitoring and DevOps pipelines.
3333

3434
## 📋 Table of Contents
3535

36-
- [Installation](#-installation)
37-
- [Quick Start](#-quick-start)
38-
- [Command Reference](#-command-reference)
39-
- [Configuration](#-configuration)
40-
- [Security Audits](#-security-audits)
41-
- [Usage Examples](#-usage-examples)
42-
- [Notifications](#-notifications)
43-
- [Custom Audits](#-custom-audits)
44-
- [Scheduling](#-scheduling)
45-
- [CI/CD Integration](#-cicd-integration)
46-
- [Advanced Features](#-advanced-features)
47-
- [FAQ](#-faq)
48-
- [Troubleshooting](#-troubleshooting)
36+
- [Installation](#installation)
37+
- [Quick Start](#quick-start)
38+
- [Command Reference](#command-reference)
39+
- [Configuration](#configuration)
40+
- [Security Audits](#security-audits)
41+
- [Usage Examples](#usage-examples)
42+
- [Notifications](#notifications)
43+
- [Custom Audits](#custom-audits)
44+
- [Scheduling](#scheduling)
45+
- [CI/CD Integration](#cicd-integration)
46+
- [Advanced Features](#advanced-features)
47+
- [FAQ](#faq)
48+
- [Troubleshooting](#troubleshooting)
4949

5050
---
5151

@@ -516,7 +516,7 @@ pipeline {
516516
],
517517
```
518518

519-
> **Output & severity:** Use `--output` and `--severity` CLI options (not config). See [Command Reference](#-command-reference) below.
519+
> **Output & severity:** Use `--output` and `--severity` CLI options (not config). See [Command Reference](#-command-reference) above.
520520
521521
---
522522

src/Commands/WardenAuditCommand.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,14 @@ protected function shouldSuppressNotifications(): bool
6262
if ($this->option('no-notify')) {
6363
return true;
6464
}
65-
return $this->output->isSilent();
65+
66+
// Check if isSilent() exists (Symfony Console 7.2+/Laravel 11+)
67+
if (method_exists($this->output, 'isSilent')) {
68+
return $this->output->isSilent();
69+
}
70+
71+
// Fallback for older Symfony Console versions
72+
return !$this->output->isVerbose();
6673
}
6774

6875
/**
@@ -316,9 +323,10 @@ protected function initializeAuditServices(): array
316323
*/
317324
protected function handleAuditFailure(AuditServiceInterface $auditService): void
318325
{
319-
$serviceName = $auditService instanceof \Dgtlss\Warden\Services\Audits\AbstractAuditService || $auditService instanceof CustomAuditWrapper
320-
? $auditService->getName()
321-
: 'Unknown service';
326+
$serviceName = $auditService->getName();
327+
if ($serviceName === '' || $serviceName === null) {
328+
$serviceName = 'Unknown service';
329+
}
322330
$this->error($serviceName . ' audit failed to run.');
323331
if ($auditService instanceof ComposerAuditService) {
324332
$findings = $auditService->getFindings();

0 commit comments

Comments
 (0)