diff --git a/code/AmIVulnerable/AmIVulnerable/Controllers/GitController.cs b/code/AmIVulnerable/AmIVulnerable/Controllers/GitController.cs index b9c8562..2578992 100644 --- a/code/AmIVulnerable/AmIVulnerable/Controllers/GitController.cs +++ b/code/AmIVulnerable/AmIVulnerable/Controllers/GitController.cs @@ -31,7 +31,7 @@ public GitController(IConfiguration configuration) { /// /// [HttpPost] - [Route("cloneRepo")] + [Route("repository")] public async Task CloneRepoToAnalyze([FromBody] RepoObject repoObject) { if (repoObject.RepoUrl is null) { return BadRequest(); @@ -71,6 +71,33 @@ public async Task CloneRepoToAnalyze([FromBody] RepoObject repoOb } } + /// Gets guid, tag, ... of all Repositories that have been cloned + /// Return all data of repos + [HttpGet] + [Route("allrepositories")] + public async Task GetRepositories() { + DataTable repositoryQuery = ExecuteMySqlCommand($"" + + $"SELECT * " + + $"FROM cve.repositories;"); + + if (repositoryQuery.Rows.Count == 0) { + return NoContent(); + } + + List list = []; + foreach (DataRow row in repositoryQuery.Rows) { + list.Add(new { + guid = row["guid"], + repoUrl = row["repoUrl"], + repoOwner = row["repoOwner"], + repoDesignation = row["repoDesignation"], + tag = row["tag"] + }); + } + + return Ok(list); + } + /// /// [HttpPost]