microsoft/hve-core

Public

mirrored from https://github.com/microsoft/hve-coreAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
docs/transparency-note

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/skills/experimental/customer-card-render/tests/fuzz_harness.py

43lines · modecode

1# Copyright (c) Microsoft Corporation.
2# SPDX-License-Identifier: MIT
3
4from __future__ import annotations
5
6import importlib.util
7import sys
8from pathlib import Path
9
10
11def _load_module():
12 script_path = Path(__file__).resolve().parents[1] / "scripts" / "generate_cards.py"
13 spec = importlib.util.spec_from_file_location("generate_cards", script_path)
14 module = importlib.util.module_from_spec(spec)
15 assert spec is not None and spec.loader is not None
16 sys.modules["generate_cards"] = module
17 spec.loader.exec_module(module)
18 return module
19
20
21MODULE = _load_module()
22
23
24def _exercise_parser(data: bytes) -> None:
25 text = data.decode("utf-8", errors="ignore")
26 MODULE.parse_frontmatter(text)
27 for heading in [
28 "Description",
29 "Scenario Narrative",
30 "How Might We",
31 "Use Case Description",
32 "User Goal",
33 ]:
34 MODULE.extract_section(text, heading)
35
36
37if __name__ == "__main__":
38 import sys
39
40 import atheris
41
42 atheris.Setup(sys.argv, _exercise_parser)
43 atheris.Fuzz()
44