Skip to content

Instantly share code, notes, and snippets.

@WoodProgrammer
Created December 20, 2020 22:32
Show Gist options
  • Save WoodProgrammer/0eded58d665105ba9e63c33e2b76b426 to your computer and use it in GitHub Desktop.
Save WoodProgrammer/0eded58d665105ba9e63c33e2b76b426 to your computer and use it in GitHub Desktop.
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