Skip to content

Commit

Permalink
Fixed an issue where CERT value was defined even when not using TLS
Browse files Browse the repository at this point in the history
  • Loading branch information
DeadPackets committed Apr 28, 2021
1 parent 0983f95 commit 048248d
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions docker_challenges/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,24 @@ class DockerConfig(db.Model):
id = db.Column(db.Integer, primary_key=True)
hostname = db.Column("hostname",db.String(64), index=True)
tls_enabled = db.Column("tls_enabled",db.Boolean,default=False, index=True)
ca_cert = db.Column("ca_cert",db.Text, index=True)
client_cert = db.Column("client_cert",db.Text, index=True)
client_key = db.Column("client_key",db.Text, index=True)
repositories = db.Column("repositories",db.Text, index=True)
ca_cert = db.Column("ca_cert",db.String, index=True)
client_cert = db.Column("client_cert",db.String, index=True)
client_key = db.Column("client_key",db.String, index=True)
repositories = db.Column("repositories",db.String, index=True)

class DockerChallengeTracker(db.Model):
"""
Docker Container Tracker. This model stores the users/teams active docker containers.
"""
id = db.Column(db.Integer, primary_key=True)
team_id = db.Column("team_id",db.String(64), index=True)
user_id = db.Column("user_id",db.String(64), index=True)
docker_image = db.Column("docker_image",db.String(128), index=True)
team_id = db.Column("team_id",db.String, index=True)
user_id = db.Column("user_id",db.String, index=True)
docker_image = db.Column("docker_image",db.String, index=True)
timestamp = db.Column("timestamp",db.Integer, index=True)
revert_time = db.Column("revert_time",db.Integer, index=True)
instance_id = db.Column("instance_id",db.String(64), index=True)
ports = db.Column('ports', db.String(64), index=True)
host = db.Column('host', db.String(64), index=True)
instance_id = db.Column("instance_id",db.String, index=True)
ports = db.Column('ports', db.String, index=True)
host = db.Column('host', db.String, index=True)


class DockerConfigForm(BaseForm):
Expand Down Expand Up @@ -232,6 +232,7 @@ def get_repositories(docker, tags=False, repos=False):

def get_unavailable_ports(docker):
tls = docker.tls_enabled
CERT = None
if not tls:
prefix = 'http'
else:
Expand Down Expand Up @@ -264,6 +265,7 @@ def get_unavailable_ports(docker):

def get_required_ports(docker, image):
tls = docker.tls_enabled
CERT = None
if not tls:
prefix = 'http'
else:
Expand Down Expand Up @@ -293,6 +295,7 @@ def get_required_ports(docker, image):

def create_container(docker, image, team, portbl):
tls = docker.tls_enabled
CERT = None
if not tls:
prefix = 'http'
else:
Expand Down Expand Up @@ -340,6 +343,7 @@ def create_container(docker, image, team, portbl):

def delete_container(docker, instance_id):
tls = docker.tls_enabled
CERT = None
if not tls:
prefix = 'http'
else:
Expand Down Expand Up @@ -544,7 +548,7 @@ def fail(user, team, challenge, request):
class DockerChallenge(Challenges):
__mapper_args__ = {'polymorphic_identity': 'docker'}
id = db.Column(None, db.ForeignKey('challenges.id'), primary_key=True)
docker_image = db.Column(db.String(128), index=True)
docker_image = db.Column(db.String, index=True)

# API
container_namespace = Namespace("container", description='Endpoint to interact with containers')
Expand Down

0 comments on commit 048248d

Please sign in to comment.