最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

The Fuzzing Book 之 樣本突變Fuzzing(二)

2023-07-21 19:27 作者:l140w4n9  | 我要投稿

class ProgramCoverage:


??def __init__(self, source_path: str) -> None:

????self._coverage = set()

????self.reports = []

????self.rest(source_path)


??def rest(self, source_path):

????self.source_path = source_path

????self._sources = []

????for filepath, dirnames, filenames in os.walk(source_path):

??????for filename in filenames:

????????if filename.endswith('.c'):

??????????fullname = os.path.join(filepath, filename)

??????????self._sources.append(fullname)


??def sources(self) -> List:

????return self._sources


??def trace(self):

????old_work_dir = os.getcwd()

????os.chdir(self.source_path)

????for source in self._sources:

??????gcov_come = subprocess.run(

????????["gcov", source],

????????stdin=subprocess.PIPE,

????????stderr=subprocess.PIPE,

????????stdout=subprocess.PIPE,

????????universal_newlines=True

??????)

??????if gcov_come.stdout != '':

????????self.reports.append((source, gcov_come.stdout))

????????gcov_file = source + ".gcov"

????????with open(gcov_file, 'r') as f:

??????????for line in f.readlines():

????????????if line.startswith('??#####:?'):

??????????????self._coverage.add((source, int(line.strip('??#####:?').split(':')[0])))

????os.chdir(old_work_dir)


??def coverage(self) -> any:

????return self._coverage


??def __repr__(self):

????out = ""

????for report in self.reports:

??????source, gcov_info = report

??????out += source + "\n"

??????out += gcov_info

??????out += '#' * 60 + '\n'

????return out



class ProgramCoverageRunner(ProgramRunner):


??def __init__(self, program: str, sources_path):

????self.program = program

????self.sources_path = sources_path

????basename = "input.txt"

????tmpdir = tempfile.mkdtemp()

????self.input_file = os.path.join(tmpdir, basename)


??def run_process(self, inp) -> subprocess.CompletedProcess:

????print(inp)

????with open(self.input_file, 'w') as f:

??????f.write(inp + '\n')

????result = subprocess.run(

??????[self.program, self.input_file],

??????stdin=subprocess.PIPE,

??????stdout=subprocess.PIPE,

??????stderr=subprocess.PIPE,

??????universal_newlines=True

????)


????cov = ProgramCoverage(self.sources_path)

????cov.trace()

????self._coverage = cov.coverage()

????return result


??def coverage(self):

????return self._coverage

The Fuzzing Book 之 樣本突變Fuzzing(二)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
贺州市| 潜江市| 锦州市| 大同县| 靖州| 澳门| 天全县| 石泉县| 连云港市| 昌宁县| 望都县| 枣庄市| 岳阳县| 罗田县| 景洪市| 景谷| 类乌齐县| 太原市| 刚察县| 旬邑县| 乌兰县| 绿春县| 舟山市| 龙泉市| 闸北区| 大田县| 惠安县| 栖霞市| 辽宁省| 汝城县| 西青区| 宝丰县| 鲁甸县| 宣武区| 台北县| 牡丹江市| 鹤山市| 镇坪县| 泊头市| 凤翔县| 玛纳斯县|