From e91dd3fd59680bca7f5e9a381882994213a17ac4 Mon Sep 17 00:00:00 2001 From: Claudio Date: Thu, 24 Oct 2024 16:34:52 +0200 Subject: [PATCH] Update stacktrace-disclosure rule and test (#3495) * Update stacktrace-disclosure.cs * Update stacktrace-disclosure.yaml --- csharp/lang/security/stacktrace-disclosure.cs | 7 +++++++ csharp/lang/security/stacktrace-disclosure.yaml | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/csharp/lang/security/stacktrace-disclosure.cs b/csharp/lang/security/stacktrace-disclosure.cs index 9c3bab216c..ffeb42f457 100644 --- a/csharp/lang/security/stacktrace-disclosure.cs +++ b/csharp/lang/security/stacktrace-disclosure.cs @@ -24,3 +24,10 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseExceptionHandler("/Error"); } } + +public void Configure(IApplicationBuilder app, IWebHostEnvironment env) +{ + if (env.IsDevelopment()) + // ok: stacktrace-disclosure + app.UseDeveloperExceptionPage(); +} diff --git a/csharp/lang/security/stacktrace-disclosure.yaml b/csharp/lang/security/stacktrace-disclosure.yaml index 1337b8582b..882989f288 100644 --- a/csharp/lang/security/stacktrace-disclosure.yaml +++ b/csharp/lang/security/stacktrace-disclosure.yaml @@ -4,8 +4,6 @@ rules: - pattern: $APP.UseDeveloperExceptionPage(...); - pattern-not-inside: | if ($ENV.IsDevelopment(...)) { - ... - $APP.UseDeveloperExceptionPage(...); ... } message: >-