""" import argparse import json import os import shutil import sys from libcodechecker import logger from libcodechecker import generic_package_context from libcodechecker import host_check from libcodechecker.analyze import log_parser from libcodechecker.analyze import analyzer from libcodechecker.analyze.analyzers import analyzer_types LOG = logger.get_logger('system') class OrderedCheckersAction(argparse.Action): """ Action to store enabled and disabled checkers and keep ordering from command line. Create separate lists based on the checker names for each analyzer. """ # Users can supply invocation to 'codechecker-analyze' as follows: # -e core -d core.uninitialized -e core.uninitialized.Assign # We must support having multiple '-e' and '-d' options and the order # specified must be kept when the list of checkers are assembled for Clang.
from thrift.Thrift import TApplicationException import shared from Authentication_v6 import ttypes as AuthTypes from libcodechecker.logger import get_logger from libcodechecker.util import split_product_url from libcodechecker.version import CLIENT_API from . import authentication_helper from . import product_helper from . import thrift_helper from .credential_manager import UserCredentials LOG = get_logger('system') def check_preconfigured_username(username, host, port): """ Checks if username supplied by using preconfigured credentials. """ if not username: LOG.error( "No username supplied! Please specify the " "username in your " "\"~/.codechecker.passwords.json\" file for " "%s:%s.", host, port) sys.exit(1)
provides the handling of permission matching and databases. """ from __future__ import print_function from __future__ import division from __future__ import absolute_import from abc import ABCMeta from abc import abstractmethod from sqlalchemy import and_ from shared.ttypes import Permission as PermissionEnum from libcodechecker.logger import get_logger LOG = get_logger('server') config_db_model = None # Module will be loaded later... class Permission(object): """ The base class for a permission declaration. """ __metaclass__ = ABCMeta def __init__(self, name, default_enable=True, inherited_from=None, managed_by=None,
""" from __future__ import print_function from __future__ import division from __future__ import absolute_import from abc import ABCMeta, abstractmethod import os import shlex import signal import subprocess import sys from libcodechecker.logger import get_logger LOG = get_logger('analyzer') class SourceAnalyzer(object): """ Base class for different source analyzers. """ __metaclass__ = ABCMeta def __init__(self, config_handler, buildaction): self.__config_handler = config_handler self.__build_action = buildaction self.__source_file = '' self.__checkers = [] @property
# ------------------------------------------------------------------------- """ This module is responsible for parsing clang-tidy output and generating plist for the plist_parser module. """ import copy import json import os import plistlib import re from libcodechecker.logger import get_logger from libcodechecker.report import generate_report_hash LOG = get_logger('analyzer.tidy') class Note(object): """ Represents a note and also this is the base class of Message. """ def __init__(self, path, line, column, message): self.path = path self.line = line self.column = column self.message = message def __eq__(self, other): return self.path == other.path and \ self.line == other.line and \
from libcodechecker import logger from libcodechecker import output_formatters from libcodechecker import util from libcodechecker.analyze import analyzer_env from libcodechecker.server import instance_manager from libcodechecker.server import server from libcodechecker.server.database import database from libcodechecker.server.database import database_status from libcodechecker.server.database.config_db_model \ import IDENTIFIER as CONFIG_META from libcodechecker.server.database.config_db_model \ import Product as ORMProduct from libcodechecker.server.database.run_db_model \ import IDENTIFIER as RUN_META LOG = logger.get_logger('server') def get_argparser_ctor_args(): """ This method returns a dict containing the kwargs for constructing an argparse.ArgumentParser (either directly or as a subparser). """ return { 'prog': 'CodeChecker server', 'formatter_class': argparse.ArgumentDefaultsHelpFormatter, # Description is shown when the command's help is queried directly
from __future__ import absolute_import import os import pickle import platform import subprocess import sys from uuid import uuid4 from libcodechecker.logger import get_logger # TODO: Cross-reference between subpacakges... from libcodechecker.analyze import analyzer_env from . import host_check LOG = get_logger('buildlogger') def execute_buildcmd(command, silent=False, env=None, cwd=None): """ Execute the the build command and continuously write the output from the process to the standard output. """ proc = subprocess.Popen(command, bufsize=-1, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd, shell=True)
Parsers for the analyzer output formats (plist ...) should create this Report which will be stored. Multiple bug identification hash-es can be generated. All hash generation algorithms should be documented and implemented here. """ import hashlib import json import os import libcodechecker.util as util from libcodechecker.logger import get_logger from libcodechecker.util import get_line LOG = get_logger('report') def generate_report_hash(path, source_file, check_name): """ !!! Compatible with the old hash before v6.0 Keep this until needed for transformation tools from the old hash to the new hash. Hash generation algoritm for older plist versions where no issue hash was generated or for the plists generated from clang-tidy where the issue hash generation feature is still missing. As the main diagnositc section the last element from the
from .database.config_db_model import Session as SessionRecord from .database.config_db_model import SystemPermission UNSUPPORTED_METHODS = [] try: from libcodechecker.libauth import cc_ldap except ImportError: UNSUPPORTED_METHODS.append('ldap') try: from libcodechecker.libauth import cc_pam except ImportError: UNSUPPORTED_METHODS.append('pam') LOG = get_logger("server") SESSION_COOKIE_NAME = _SCN class _Session(object): """A session for an authenticated, privileged client connection.""" def __init__(self, token, username, groups, session_lifetime, refresh_time, is_root=False, database=None, last_access=None, can_expire=True):
def init_logger(level, logger_name='system'): logger.setup_logger(level) global LOG LOG = logger.get_logger(logger_name)
from datetime import datetime import cProfile import pstats from functools import wraps try: from StringIO import StringIO except ImportError: from io import BytesIO as StringIO from libcodechecker import logger from libcodechecker.logger import get_logger LOG = get_logger('profiler') class Timer(object): """ Simple timer context manager to measure code block execution time. """ def __init__(self, block_name=''): self.block_name = block_name def __enter__(self): self.before = datetime.now() def __exit__(self, timer_type, value, traceback): after = datetime.now()