Created
December 20, 2020 22:32
-
-
Save WoodProgrammer/0eded58d665105ba9e63c33e2b76b426 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
from flask import Flask, request, jsonify | |
import ssl | |
import sys | |
from container_utils import check_image, get_allowed_list | |
app = Flask(__name__) | |
@app.route("/validate", methods=["POST"]) | |
def validate(): | |
allowed = True | |
allowed_list = get_allowed_list() | |
image = request.json["request"]["object"]["spec"]["containers"][0]["image"] | |
is_allowed = check_image(image, allowed_list) | |
if is_allowed == False: | |
allowed = False | |
response = { | |
"response": { | |
"allowed": allowed, | |
"uid": request.json["request"]["uid"], | |
"status": {"message": "Image repository is not allowed "}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment