Code source de Sylexe
SylexeRadzen/SQLManagement/Services
public async Task<List<SylexeReports>> GetReportsAsync() { return await dbContext.sylexeReports.ToListAsync(); }
public async Task<SylexeReports> AddReportsAsync(SylexeReports report) { try { dbContext.sylexeReports.Add(report); await dbContext.SaveChangesAsync(); } catch (Exception) { throw; } return report; }
public async Task<SylexeReports> UpdateReportsAsync(SylexeReports report) { try { var ReportsExist = dbContext.sylexeReports.FirstOrDefault(l => l.Id == report.Id); if (ReportsExist != null) { dbContext.Update(report); await dbContext.SaveChangesAsync(); } } catch (Exception) { throw; } return report; }
public async Task DeleteCategoriesAsync(SylexeReports categories) { try { dbContext.sylexeReports.Remove(categories); await dbContext.SaveChangesAsync(); } catch (Exception) { throw; } }
SylexeRadzen/Pages/Analyze.razor
void ExecTrivyScan(string DockerScan) { Process serverSideProcess = new Process(); serverSideProcess.StartInfo.FileName = Environment.GetEnvironmentVariable("docker"); serverSideProcess.StartInfo.FileName = @"C:\Program Files\Docker\Docker\resources\bin\docker.exe"; var path = Path.Combine(WebEnvironment.ContentRootPath, WebEnvironment.EnvironmentName); DateTime currentDateTime = DateTime.Now; string formattedDateTime = currentDateTime.ToString("dd-MMMM-yyyy-HH:mm:ss"); string input = (DockerScan + "-" + formattedDateTime); string temp = Regex.Replace(input, @"\/", "-"); string pathOfJson = Regex.Replace(temp, @":", "_"); serverSideProcess.StartInfo.Arguments = String.Format("run -v {0}:/result aquasec/trivy:0.34.0 -d image -f json -o /result/{1}.json {2}", path, pathOfJson, DockerScan); serverSideProcess.EnableRaisingEvents = true; serverSideProcess.StartInfo.UseShellExecute = true; serverSideProcess.Start(); _sylexeService.AddReportsAsync(new SylexeReports { Name = DockerScan, Timestamp = formattedDateTime, Path = pathOfJson+".json" }); }