Skip to content

Commit

Permalink
Change Query structure for swagger and [desc]
Browse files Browse the repository at this point in the history
- List still uses body, it is callable from curl per bash, but not work in swagger
  • Loading branch information
Kretchen001 committed May 21, 2024
1 parent 3ae6e78 commit 6f855dd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions code/AmIVulnerable/AmIVulnerable/Controllers/DbController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,14 @@ public IActionResult GetFullTextCve([FromQuery] string? cve_number) {
/// <returns>Ok with result. NoContent if empty.</returns>
[HttpGet]
[Route("checkSinglePackage")]
public IActionResult CheckSinglePackage([FromQuery] PackageForApi packageName) {
public IActionResult CheckSinglePackage([FromQuery] string PackageName,
[FromQuery] string? PackageVersion) {
if (!(this.Request.Headers.Accept.Equals("application/json") || this.Request.Headers.Accept.Equals("*/*"))) {
return StatusCode(406);
}
using (Operation.Time($"Complete Time for Query-SingleSearch after Package \"{packageName}\"")) {
using (Operation.Time($"Complete Time for Query-SingleSearch after Package \"{PackageName}\"")) {
List<CveResult> results = [];
DataTable dtResult = SearchInMySql(packageName.PackageName);
DataTable dtResult = SearchInMySql(PackageName);
// convert the result
foreach (DataRow x in dtResult.Rows) {
CveResult y = new CveResult() {
Expand Down Expand Up @@ -240,13 +241,14 @@ public IActionResult CheckSinglePackage([FromQuery] PackageForApi packageName) {
}

/// <summary>
/// Search for a list of packages
/// Search for a list of packages.
/// Not useable in swagger because of body - but curl works fine.
/// </summary>
/// <param name="packages">List of tuple: package, version</param>
/// <returns>OK, if exists. OK, if no package list searched. NoContent if not found.</returns>
[HttpGet]
[Route("checkPackageList")]
public async Task<IActionResult> CheckPackageListAsync([FromQuery] List<PackageForApi> packages) {
public async Task<IActionResult> CheckPackageListAsync([FromBody] List<PackageForApi> packages) {

Check warning on line 251 in code/AmIVulnerable/AmIVulnerable/Controllers/DbController.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 251 in code/AmIVulnerable/AmIVulnerable/Controllers/DbController.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 251 in code/AmIVulnerable/AmIVulnerable/Controllers/DbController.cs

View workflow job for this annotation

GitHub Actions / build-and-test-windows-latest

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 251 in code/AmIVulnerable/AmIVulnerable/Controllers/DbController.cs

View workflow job for this annotation

GitHub Actions / build-and-test-windows-latest

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 251 in code/AmIVulnerable/AmIVulnerable/Controllers/DbController.cs

View workflow job for this annotation

GitHub Actions / build-and-test-macOS-latest

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 251 in code/AmIVulnerable/AmIVulnerable/Controllers/DbController.cs

View workflow job for this annotation

GitHub Actions / build-and-test-macOS-latest

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
if (!(this.Request.Headers.Accept.Equals("application/json") || this.Request.Headers.Accept.Equals("*/*"))) {
return StatusCode(406);
}
Expand Down

0 comments on commit 6f855dd

Please sign in to comment.