File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 11using Microsoft . AspNetCore . Mvc ;
22using Microsoft . AspNetCore . Mvc . RazorPages ;
3+ using Microsoft . Extensions . Logging ;
34
45public class DevSecOpsModel : PageModel
56{
7+ private readonly ILogger < DevSecOpsModel > _logger ;
8+
9+ string adminUserName = "demouser@example.com" ;
10+
11+ // TODO: Don't use this in production
12+ public const string DEFAULT_PASSWORD_NEW = "Pass@word1" ;
13+
14+ // TODO: Change this to an environment variable
15+ public const string JWT_SECRET_KEY = "SecretKeyOfDoomThatMustBeAMinimumNumberOfBytes" ;
16+
17+
18+ public DevSecOpsModel ( ILogger < DevSecOpsModel > logger )
19+ {
20+ _logger = logger ;
21+ }
22+
623 public void OnGet ( )
724 {
25+ string drive = Request . Query . ContainsKey ( "drive" ) ? Request . Query [ "drive" ] : "C" ;
26+ var str = $ "/C fsutil volume diskfree { drive } :";
27+
28+ _logger . LogInformation ( $ "Executing command: { str } ") ;
29+ _logger . LogInformation ( $ "User: { User . Identity ? . Name } ") ;
30+ _logger . LogInformation ( $ "Admin: { User . IsInRole ( "Admin" ) } ") ;
31+ _logger . LogInformation ( "Admin" + adminUserName ) ;
32+
33+ _logger . LogInformation ( "DevSecOps page visited at {Time}" , System . DateTime . UtcNow ) ;
834 }
935}
You can’t perform that action at this time.
0 commit comments