Skip to content

Commit 534c4a2

Browse files
author
MPCoreDeveloper
committed
new icon for nuget
1 parent 543de45 commit 534c4a2

File tree

7 files changed

+120
-0
lines changed

7 files changed

+120
-0
lines changed

PACKAGE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ Both methods are defined in **`SafeWebCore.Extensions.ServiceCollectionExtension
134134
- 🔌 **Extensible** — custom `IHeaderPolicy` implementations
135135
- 📊 **CSP violation reporting** — built-in `/csp-report` endpoint using Reporting API v1
136136

137+
## Validate Your Headers
138+
139+
After deploying, test your security headers with:
140+
141+
- **[securityheaders.com](https://securityheaders.com/)** — Grades all response headers A+ through F. With the Strict A+ preset you should score **A+** immediately.
142+
- **[Google CSP Evaluator](https://csp-evaluator.withgoogle.com/)** — Paste your `Content-Security-Policy` value to check for misconfigurations (missing `object-src`, `'unsafe-inline'` without nonce, missing `'strict-dynamic'`, etc.).
143+
137144
## Documentation
138145

139146
Full documentation: [github.com/MPCoreDeveloper/SafeWebCore/docs](https://github.com/MPCoreDeveloper/SafeWebCore/tree/master/docs)

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,31 @@ dotnet-coverage collect -f cobertura -o coverage.cobertura.xml dotnet test
249249

250250
---
251251

252+
## ✅ Validate Your Security Headers
253+
254+
After deploying your application, verify your headers with these tools:
255+
256+
### 1. [securityheaders.com](https://securityheaders.com/)
257+
258+
Scans **all** response headers and grades your site **A+** through **F**. Validates HSTS, CSP, X-Frame-Options, Permissions-Policy, Referrer-Policy, and more.
259+
260+
> With SafeWebCore's Strict A+ preset you should score **A+** immediately.
261+
262+
### 2. [Google CSP Evaluator](https://csp-evaluator.withgoogle.com/)
263+
264+
Paste your `Content-Security-Policy` header value to check for common CSP misconfigurations:
265+
- ❌ Missing `object-src 'none'`
266+
-`'unsafe-inline'` without a nonce or hash
267+
- ❌ Missing `'strict-dynamic'` for trust propagation
268+
- ❌ Overly permissive wildcards (`*`, `https:`)
269+
- ✅ Nonce-based policy with `'strict-dynamic'` (SafeWebCore default)
270+
271+
### 3. Browser DevTools
272+
273+
Open **DevTools → Network tab → Response Headers** to inspect headers on every request. Any CSP violations will also appear in the **Console** tab.
274+
275+
---
276+
252277
## 🤝 Contributing
253278

254279
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

docs/csp-configuration.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,58 @@ SafeWebCore correctly handles deprecated directives:
365365
| `block-all-mixed-content` | `[Obsolete]` — modern browsers block mixed content by default | `upgrade-insecure-requests` |
366366

367367
Both deprecated directives are excluded from `CspBuilder` but remain available on `CspOptions` with `[Obsolete]` attributes and compiler warnings.
368+
369+
---
370+
371+
## Validate Your CSP
372+
373+
After deploying your application, always validate your Content Security Policy using these tools:
374+
375+
### [securityheaders.com](https://securityheaders.com/)
376+
377+
Scans **all** response headers and grades your site **A+** through **F**. It checks:
378+
- Content-Security-Policy presence and quality
379+
- Strict-Transport-Security (HSTS)
380+
- X-Frame-Options / frame-ancestors
381+
- Permissions-Policy
382+
- Referrer-Policy
383+
- X-Content-Type-Options
384+
- Cross-Origin policies (COEP, COOP, CORP)
385+
386+
> 💡 With SafeWebCore's Strict A+ preset you should score **A+** immediately.
387+
388+
**How to use:**
389+
1. Deploy your application to a public URL (or use a tunnel like ngrok for local testing)
390+
2. Visit [securityheaders.com](https://securityheaders.com/)
391+
3. Enter your URL and click **Scan**
392+
4. Review the grade and any missing headers
393+
394+
### [Google CSP Evaluator](https://csp-evaluator.withgoogle.com/)
395+
396+
Google's dedicated CSP analyzer checks your policy for common misconfigurations:
397+
398+
| Check | SafeWebCore Default |
399+
|-------|-------------------|
400+
| Missing `object-src` | ✅ Set to `'none'` |
401+
| `'unsafe-inline'` without nonce/hash | ✅ Uses nonce-only |
402+
| Missing `'strict-dynamic'` | ✅ Enabled by default |
403+
| Missing `base-uri` | ✅ Set to `'none'` |
404+
| Overly permissive wildcards (`*`) | ✅ No wildcards in defaults |
405+
| Missing `script-src` | ✅ Nonce + strict-dynamic |
406+
407+
**How to use:**
408+
1. Open your site in the browser and copy the `Content-Security-Policy` header value from DevTools (Network tab → Response Headers)
409+
2. Visit [csp-evaluator.withgoogle.com](https://csp-evaluator.withgoogle.com/)
410+
3. Paste the header value and click **Check CSP**
411+
4. Review the findings — green means safe, yellow/red means attention needed
412+
413+
### Browser DevTools
414+
415+
Your browser also reports CSP violations in real-time:
416+
417+
1. Open **DevTools** (F12)
418+
2. **Network tab** → Click any request → **Response Headers** to see the full CSP header
419+
3. **Console tab** → Any CSP violations will appear as errors with the blocked resource and violated directive
420+
4. Use this during development to catch issues before deployment
421+
422+
> ⚠️ **Important:** Always test in production (or staging) with the real CSP header. Development servers may not have all headers enabled.

docs/getting-started.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,19 @@ content-security-policy: default-src 'none'; script-src 'nonce-abc123...' 'stric
121121
3. Enter your URL and scan
122122
4. You should see an **A+** rating
123123

124+
This tool grades **all** security headers (HSTS, CSP, X-Frame-Options, Permissions-Policy, etc.) from A+ through F.
125+
126+
### Option D: Google CSP Evaluator
127+
128+
1. Copy the `Content-Security-Policy` header value from DevTools or `curl` output
129+
2. Visit [csp-evaluator.withgoogle.com](https://csp-evaluator.withgoogle.com/)
130+
3. Paste the header value and click **Check CSP**
131+
4. All checks should be green with SafeWebCore's defaults
132+
133+
Google's CSP Evaluator checks for common misconfigurations like missing `object-src`, `'unsafe-inline'` without nonce, and missing `'strict-dynamic'`.
134+
135+
> 💡 **Tip:** Always validate with both tools after any CSP changes. See the [CSP Configuration Guide](csp-configuration.md#validate-your-csp) for detailed usage instructions.
136+
124137
## Next Steps
125138

126139
| Topic | Link |

icon.png

24.7 KB
Loading

src/SafeWebCore/Builder/CspBuilder.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ namespace SafeWebCore.Builder;
5454
/// <c>.ScriptSrc("'sha256-abc123...' 'strict-dynamic'")</c>. This is a CSP Level 3 feature for
5555
/// allowing specific inline scripts/styles by their SHA-256, SHA-384, or SHA-512 digest.
5656
/// </para>
57+
/// <para>
58+
/// <b>Validate your policy:</b> After deploying, test your CSP headers using these tools:
59+
/// </para>
60+
/// <list type="bullet">
61+
/// <item><description><see href="https://securityheaders.com/">securityheaders.com</see> — Scans all response
62+
/// headers and grades your site A+ through F. Validates HSTS, CSP, Permissions-Policy, and more.</description></item>
63+
/// <item><description><see href="https://csp-evaluator.withgoogle.com/">Google CSP Evaluator</see> — Analyzes your
64+
/// Content-Security-Policy for common misconfigurations (e.g. missing <c>object-src</c>, <c>'unsafe-inline'</c>
65+
/// without nonce, missing <c>'strict-dynamic'</c>).</description></item>
66+
/// </list>
5767
/// </remarks>
5868
public sealed class CspBuilder
5969
{

src/SafeWebCore/Options/CspOptions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ namespace SafeWebCore.Options;
3333
/// Use <see cref="SafeWebCore.Builder.CspBuilder"/> for a fluent API, or C# <c>with</c> expressions
3434
/// to modify individual directives from a preset.
3535
/// </para>
36+
/// <para>
37+
/// <b>Validate your policy after deployment:</b>
38+
/// </para>
39+
/// <list type="bullet">
40+
/// <item><description><see href="https://securityheaders.com/">securityheaders.com</see> — Grades all security
41+
/// headers (A+ through F), including CSP, HSTS, Permissions-Policy, and X-Frame-Options.</description></item>
42+
/// <item><description><see href="https://csp-evaluator.withgoogle.com/">Google CSP Evaluator</see> — Analyzes your
43+
/// CSP for misconfigurations such as missing <c>object-src</c>, <c>'unsafe-inline'</c> without nonce, or
44+
/// missing <c>'strict-dynamic'</c>.</description></item>
45+
/// </list>
3646
/// </remarks>
3747
public record CspOptions
3848
{

0 commit comments

Comments
 (0)