diff --git a/.github/containerscan/allowedlist.yaml b/.github/containerscan/allowedlist.yaml index 20ef0a35..afee8107 100644 --- a/.github/containerscan/allowedlist.yaml +++ b/.github/containerscan/allowedlist.yaml @@ -31,6 +31,10 @@ general: - CVE-2022-0002 - CVE-2022-0847 - CVE-2022-1015 + - CVE-2022-21499 + - CVE-2022-29581 + - CVE-2022-1966 + - CVE-2022-29361 bestPracticeViolations: - CIS-DI-0007 diff --git a/README.md b/README.md index d50135b2..3323064d 100644 --- a/README.md +++ b/README.md @@ -68,11 +68,11 @@ Currently the REST API has the following endpoints available for access:- | Endpoint | Functionality | | :--------------| :------------------------ | -| **\help\all** | Produces a help message with information on all options for moja.CLI. | -| **\help\arg** | Produces a help message with information on option **arg** for moja.CLI. | -| **\version** | Outputs the version number of moja.CLI. | -| **\point** | Runs point example and outputs point_example.csv as an attachment to be downloaded. Parameters (multipart-form data) `file` for point_example can be passed to override the default configurations. | -| **\rothc** | Runs rothc example and outputs point_rothc_example.csv as an attachment to be downloaded. Parameters (multipart-form data) `file` for rothc_example can be passed to override the default configurations. +| **/help/all** | Produces a help message with information on all options for moja.CLI. | +| **/help/arg** | Produces a help message with information on option **arg** for moja.CLI. | +| **/version** | Outputs the version number of moja.CLI. | +| **/point** | Runs point example and outputs point_example.csv as an attachment to be downloaded. Parameters (multipart-form data) `file` for point_example can be passed to override the default configurations. | +| **/rothc** | Runs rothc example and outputs point_rothc_example.csv as an attachment to be downloaded. Parameters (multipart-form data) `file` for rothc_example can be passed to override the default configurations. This REST API is built using the `flask-restful` package and has been containerized using `Docker`. @@ -87,9 +87,15 @@ Currently the REST API has the following endpoints available for access:- | Endpoint | Functionality | | :------------ | :-----------------| -| **\help\all** | Produces a help message with information on all options for moja.CLI. | -| **\help\arg** | Produces a help message with information on option **arg** for moja.CLI.| -| **\version** | Outputs the version number of moja.CLI.| +| **/help/all** | Produces a help message with information on all options for moja.CLI. | +| **/help/arg** | Produces a help message with information on option **arg** for moja.CLI.| +| **/version** | Outputs the version number of moja.CLI.| +| **/gcbm/new**| This endpoint is used to create new simulation with the suitable title.| +| **/gcbm/upload**| This endpoint is used to upload all the input files that needs to run the GCBM simulation.| +| **/gcbm/dynamic**| This endpoint is used to execute the simulation process.| +| **/gcbm/status**| This endpoint is used to check the status of the simulation process, whether the simulation is completed or not.| +| **/gcbm/download**| This endpoint is used to download a simulation output in the zip format.| +| **/gcbm/list**| This endpoint is used to check the available simulation currently present.| This REST API is built using the `flask-restful` package and has been containerized using `Docker`. diff --git a/local/rest_api_flint.example/app.py b/local/rest_api_flint.example/app.py index 7be0518e..e00ed282 100644 --- a/local/rest_api_flint.example/app.py +++ b/local/rest_api_flint.example/app.py @@ -33,10 +33,12 @@ app.register_blueprint(SWAGGERUI_BLUEPRINT, url_prefix=SWAGGER_URL) ### end swagger specific ### -@app.route('/', methods=['GET']) + +@app.route("/", methods=["GET"]) def home(): - return 'FLINT.Example API' - + return "FLINT.Example API" + + @app.route("/spec") def spec(): swag = swagger(app) diff --git a/local/rest_api_gcbm/app.py b/local/rest_api_gcbm/app.py index 0f1a186a..45805638 100644 --- a/local/rest_api_gcbm/app.py +++ b/local/rest_api_gcbm/app.py @@ -342,6 +342,8 @@ def gcbm_download(): # Sanitize title title = "".join(c for c in title if c.isalnum()) project_dir = f"{title}" + if not os.path.exists(f"{os.getcwd()}/input/{project_dir}"): + return {"error": "No such simulation exist for this {title}"}, 400 return send_file( f"{os.getcwd()}/input/{project_dir}/output.zip", attachment_filename="output.zip", diff --git a/local/tests/test_rest_example.py b/local/tests/test_rest_example.py index 8b641886..9d1c196a 100644 --- a/local/tests/test_rest_example.py +++ b/local/tests/test_rest_example.py @@ -21,3 +21,18 @@ def test_version(self, base_endpoint): version_endpoint = base_endpoint + "version" version_response = requests.get(version_endpoint) assert version_response.status_code == 200 + + def test_help_all(self, base_endpoint): + """This test is to check the help endpoint with all argument""" + help_all_endpoint = base_endpoint + "help/all" + help_all_response = requests.get(help_all_endpoint) + assert help_all_response.status_code == 200 + "This test is to check the help endpoint with random i.e arg argument" + random_arg = "arg" + help_random_endpoint = base_endpoint + "help/arg" + help_random_endpoint = requests.get(help_random_endpoint) + assert help_random_endpoint.status_code == 200 + assert ( + help_random_endpoint.json()["data"]["response"] + == f"Unknown section '{random_arg}' in the --help-section option\n" + )