Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for dockerfiles #81

Merged
merged 13 commits into from
Apr 16, 2018
Prev Previous commit
Next Next commit
Make better check for the latest tag in the dockerfile
Signed-off-by: lachmanfrantisek <flachman@redhat.com>
lachmanfrantisek committed Apr 16, 2018
commit b77caa4cd2a8c495bc7a69ecfecb50fa5f6ac0d8
32 changes: 21 additions & 11 deletions colin/checks/dockerfile/from_tag.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
from colin.checks.abstract.dockerfile import InstructionCheck
from colin.checks.abstract.dockerfile import DockerfileCheck
from colin.checks.result import CheckResult
from colin.core.target import ImageName


class FromTagCheck(InstructionCheck):
class FromTagCheck(DockerfileCheck):

def __init__(self):
super().__init__(name="is_tag_not_latest",
message="",
description="",
reference_url="https://docs.docker.com/engine/reference/builder/#from",
tags=["from", "dockerfile", "latest"],
instruction="FROM",
value_regex=".*/latest$",
required=False)
# TODO: Does not check if there is no tag => use ImageName parsing.
super().__init__(name="from_tag_not_latest",
message="In FROM, tag has to be specified and not 'latest'.",
description="Using the 'latest' tag may cause unpredictable builds."
"It is recommended that a specific tag is used in the FROM.",
reference_url="https://fedoraproject.org/wiki/Container:Guidelines#FROM",
tags=["from", "dockerfile", "baseimage", "latest"])

def check(self, target):
im = ImageName.parse(target.instance.baseimage)
passed = im.tag and im.tag != "latest"
return CheckResult(ok=passed,
severity=self.severity,
description=self.description,
message=self.message,
reference_url=self.reference_url,
check_name=self.name,
logs=[])