How to use the colin.core.checks.abstract_check.AbstractCheck function in colin

To help you get started, we’ve selected a few colin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github user-cont / colin / tests / data / a_check / __init__.py View on Github external
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .
#

from colin.core.checks.abstract_check import AbstractCheck


class FunkyCheck(AbstractCheck):
    name = "this-is-a-funky-check"

    def __init__(self):
        super(FunkyCheck, self).__init__(
            message="yes!",
            description="no",
            reference_url="https://nope.example.com/",
            tags=["yes", "and", "no"]
        )


class ThisIsNotAChekk(AbstractCheck):
    name = "this-is-not-a-check"

    def __init__(self):
        super(ThisIsNotAChekk, self).__init__(
github user-cont / colin / tests / data / a_check / __init__.py View on Github external
from colin.core.checks.abstract_check import AbstractCheck


class FunkyCheck(AbstractCheck):
    name = "this-is-a-funky-check"

    def __init__(self):
        super(FunkyCheck, self).__init__(
            message="yes!",
            description="no",
            reference_url="https://nope.example.com/",
            tags=["yes", "and", "no"]
        )


class ThisIsNotAChekk(AbstractCheck):
    name = "this-is-not-a-check"

    def __init__(self):
        super(ThisIsNotAChekk, self).__init__(
            message="yes!",
            description="no",
            reference_url="https://nope.example.com/",
            tags=["yes", "and", "no"]
        )


class ThisIsAlsoNotAChekk(object):
    name = "this-is-also-not-a-check"

    def __init__(self):
        super(ThisIsAlsoNotAChekk, self).__init__(
github user-cont / colin / colin / core / checks / abstract_check.py View on Github external
def save_checks_to_json(file, checks):
        json.dump(obj=AbstractCheck.json_from_all_checks(checks=checks),
                  fp=file,
                  indent=4)
github user-cont / colin / colin / core / checks / abstract_check.py View on Github external
    @staticmethod
    def save_checks_to_json(file, checks):
        json.dump(obj=AbstractCheck.json_from_all_checks(checks=checks),
                  fp=file,
                  indent=4)


class DockerfileAbstractCheck(AbstractCheck):
    check_type = "dockerfile"


class ImageAbstractCheck(AbstractCheck):
    check_type = "image"


class FilesystemAbstractCheck(AbstractCheck):
    pass
github user-cont / colin / colin / cli / colin.py View on Github external
try:
        if not debug:
            logging.basicConfig(stream=six.StringIO())

        log_level = _get_log_level(debug=debug,
                                   verbose=verbose)
        checks = get_checks(ruleset_name=ruleset,
                            ruleset_file=ruleset_file,
                            logging_level=log_level,
                            tags=tag,
                            checks_paths=checks_paths,
                            skips=skip)
        _print_checks(checks=checks)

        if json:
            AbstractCheck.save_checks_to_json(file=json, checks=checks)
    except ColinException as ex:
        logger.error("An error occurred: %r", ex)
        if debug:
            raise
        else:
            raise click.ClickException(str(ex))
    except Exception as ex:
        logger.error("An error occurred: %r", ex)
        if debug:
            raise
        else:
            raise click.ClickException(str(ex))
github user-cont / colin / colin / core / checks / abstract_check.py View on Github external
result_list = []
            for check in group_checks:
                result_list.append(check.json)

            result_json[group] = result_list
        return result_json

    @staticmethod
    def save_checks_to_json(file, checks):
        json.dump(obj=AbstractCheck.json_from_all_checks(checks=checks),
                  fp=file,
                  indent=4)


class DockerfileAbstractCheck(AbstractCheck):
    check_type = "dockerfile"


class ImageAbstractCheck(AbstractCheck):
    check_type = "image"


class FilesystemAbstractCheck(AbstractCheck):
    pass
github user-cont / colin / colin / core / checks / abstract_check.py View on Github external
result_json[group] = result_list
        return result_json

    @staticmethod
    def save_checks_to_json(file, checks):
        json.dump(obj=AbstractCheck.json_from_all_checks(checks=checks),
                  fp=file,
                  indent=4)


class DockerfileAbstractCheck(AbstractCheck):
    check_type = "dockerfile"


class ImageAbstractCheck(AbstractCheck):
    check_type = "image"


class FilesystemAbstractCheck(AbstractCheck):
    pass
github user-cont / colin / colin / core / checks / fmf_check.py View on Github external
logger.debug("get FMF metadata for test (path:%s name=%s)", path, name)
    # ignore items with @ in names, to avoid using unreferenced items
    items = [x for x in fmf_tree.climb() if x.name.endswith("/" + name) and "@" not in x.name]
    if object_list:
        return items
    if len(items) == 1:
        output = items[0]
    elif len(items) > 1:
        raise Exception("There is more FMF test metadata for item by name:{}({}) {}".format(
            name, len(items), [x.name for x in items]))
    elif not items:
        raise Exception("Unable to get FMF metadata for: {}".format(name))
    return output


class FMFAbstractCheck(AbstractCheck):
    """
    Abstract class for checks and loading metadata from FMF format
    """
    metadata = None
    name = None
    fmf_metadata_path = None

    def __init__(self):
        """
        wraps parameters to COLIN __init__ method format
        """
        if not self.metadata:
            self.metadata = receive_fmf_metadata(name=self.name, path=self.fmf_metadata_path)
        master_class = super(FMFAbstractCheck, self)
        kwargs = {}
        try:
github user-cont / colin / colin / core / checks / containers.py View on Github external
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .
#

from .abstract_check import AbstractCheck


class ContainerCheck(AbstractCheck):
    pass