mirror of
https://github.com/rosenpass/rosenpass.git
synced 2026-02-28 14:33:37 -08:00
feat: add model name to log entries
This commit is contained in:
@@ -34,15 +34,17 @@
|
|||||||
* ~~refactor filtering in run_proverif (see karo's comment)~~
|
* ~~refactor filtering in run_proverif (see karo's comment)~~
|
||||||
* ~configurable target directory~
|
* ~configurable target directory~
|
||||||
* ~lark parser: multiline comments, how???~
|
* ~lark parser: multiline comments, how???~
|
||||||
|
* ~parse errors~
|
||||||
|
* ~error when trying with: `nix run .# -- parse ../target/proverif/01_secrecy.entry.i.pv`~
|
||||||
|
* ~`in(C, Cinit_conf(Ssskm, Spsk, Sspkt, ic));`~
|
||||||
|
* ~ ^~
|
||||||
|
* ~04_dos… has a syntax error (see below)~
|
||||||
|
|
||||||
## Next Steps
|
## Next Steps
|
||||||
|
|
||||||
* integrate marzipan.awk into Python, somehow
|
* integrate marzipan.awk into Python, somehow
|
||||||
* options term special cases (c.f. manual page 133, starting with "fun" term)
|
* options term special cases (c.f. manual page 133, starting with "fun" term)
|
||||||
* complete with CryptoVerif options
|
* complete with CryptoVerif options
|
||||||
* error when trying with: `nix run .# -- parse ../target/proverif/01_secrecy.entry.i.pv`
|
|
||||||
* `in(C, Cinit_conf(Ssskm, Spsk, Sspkt, ic));`
|
|
||||||
* ^
|
|
||||||
* rewrite marzipan.awk into Python/LARK
|
* rewrite marzipan.awk into Python/LARK
|
||||||
* define a LARK grammar for marzipan.awk rules
|
* define a LARK grammar for marzipan.awk rules
|
||||||
* write python code for processing marzipan rules, e.g. alias replacement (step: i.pv->o.pv)
|
* write python code for processing marzipan rules, e.g. alias replacement (step: i.pv->o.pv)
|
||||||
|
|||||||
@@ -14,6 +14,23 @@ console = pkgs.rich.console.Console()
|
|||||||
logger = pkgs.logging.getLogger(__name__)
|
logger = pkgs.logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def set_logging_logrecordfactory(filename):
|
||||||
|
old_factory = pkgs.logging.getLogRecordFactory()
|
||||||
|
|
||||||
|
def record_factory(*args, **kwargs):
|
||||||
|
record = old_factory(*args, **kwargs)
|
||||||
|
record.filename = filename
|
||||||
|
return record
|
||||||
|
|
||||||
|
pkgs.logging.setLogRecordFactory(record_factory)
|
||||||
|
|
||||||
|
|
||||||
|
#def set_logging_format(max_length):
|
||||||
|
# pass
|
||||||
|
# #format_str = "{levelname:<8} {filename:<" + str(max_length + 2) + "} {message}"
|
||||||
|
# #pkgs.logging.basicConfig(level=pkgs.logging.DEBUG, style="{", format=format_str)
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
def main():
|
def main():
|
||||||
pkgs.logging.basicConfig(level=pkgs.logging.DEBUG)
|
pkgs.logging.basicConfig(level=pkgs.logging.DEBUG)
|
||||||
@@ -50,7 +67,7 @@ def clean_line(prev_line, line):
|
|||||||
return prev_line
|
return prev_line
|
||||||
|
|
||||||
|
|
||||||
def run_proverif(file, extra_args=[]):
|
def run_proverif(file, log_file, extra_args=[]):
|
||||||
params = ["proverif", "-test", *extra_args, file]
|
params = ["proverif", "-test", *extra_args, file]
|
||||||
logger.debug(params)
|
logger.debug(params)
|
||||||
|
|
||||||
@@ -63,7 +80,9 @@ def run_proverif(file, extra_args=[]):
|
|||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
prev_line = None
|
prev_line = None
|
||||||
|
with open(log_file, "a") as log:
|
||||||
for line in process.stdout:
|
for line in process.stdout:
|
||||||
|
log.write(line)
|
||||||
cleaned_line = clean_line(prev_line, line)
|
cleaned_line = clean_line(prev_line, line)
|
||||||
prev_line = line
|
prev_line = line
|
||||||
if cleaned_line is not None:
|
if cleaned_line is not None:
|
||||||
@@ -83,6 +102,9 @@ def run_proverif(file, extra_args=[]):
|
|||||||
logger.error(
|
logger.error(
|
||||||
f"Proverif exited with a non-zero error code {params}: {return_code}"
|
f"Proverif exited with a non-zero error code {params}: {return_code}"
|
||||||
)
|
)
|
||||||
|
if prev_line is not None:
|
||||||
|
logger.error(f"Last line of log file {log_file}:")
|
||||||
|
logger.error(f"> {prev_line.rstrip()}")
|
||||||
exit(return_code)
|
exit(return_code)
|
||||||
|
|
||||||
|
|
||||||
@@ -193,7 +215,12 @@ def analyze(repo_path, output):
|
|||||||
|
|
||||||
entries = []
|
entries = []
|
||||||
analysis_dir = pkgs.os.path.join(repo_path, "analysis")
|
analysis_dir = pkgs.os.path.join(repo_path, "analysis")
|
||||||
entries.extend(sorted(pkgs.glob.glob(str(analysis_dir) + "/*.entry.mpv")))
|
full_paths = sorted(pkgs.glob.glob(str(analysis_dir) + "/*.entry.mpv"))
|
||||||
|
entries.extend(full_paths)
|
||||||
|
|
||||||
|
#modelnames = [pkgs.os.path.basename(path).replace('.entry.mpv', '') for path in full_paths]
|
||||||
|
#max_length = max(len(modelname) for modelname in modelnames) if modelnames else 0
|
||||||
|
#set_logging_format(max_length)
|
||||||
|
|
||||||
with pkgs.concurrent.futures.ProcessPoolExecutor() as executor:
|
with pkgs.concurrent.futures.ProcessPoolExecutor() as executor:
|
||||||
futures = {
|
futures = {
|
||||||
@@ -231,12 +258,14 @@ def clean(repo_path, output):
|
|||||||
|
|
||||||
|
|
||||||
def metaverif(repo_path, tmpdir, file):
|
def metaverif(repo_path, tmpdir, file):
|
||||||
print(f"Start metaverif on {file}")
|
|
||||||
# Extract the name using regex
|
# Extract the name using regex
|
||||||
name_match = pkgs.re.search(r"([^/]*)(?=\.mpv)", file)
|
name_match = pkgs.re.search(r"([^/]*)(?=\.entry\.mpv)", file)
|
||||||
if name_match:
|
if name_match:
|
||||||
name = name_match.group(0) # Get the matched name
|
name = name_match.group(0) # Get the matched name
|
||||||
|
|
||||||
|
set_logging_logrecordfactory(name)
|
||||||
|
logger.info(f"Start metaverif on {file}")
|
||||||
|
|
||||||
# Create the file paths
|
# Create the file paths
|
||||||
cpp_prep = pkgs.os.path.join(tmpdir, f"{name}.i.pv")
|
cpp_prep = pkgs.os.path.join(tmpdir, f"{name}.i.pv")
|
||||||
awk_prep = pkgs.os.path.join(tmpdir, f"{name}.o.pv")
|
awk_prep = pkgs.os.path.join(tmpdir, f"{name}.o.pv")
|
||||||
@@ -253,9 +282,8 @@ def metaverif(repo_path, tmpdir, file):
|
|||||||
|
|
||||||
ta, res, ctr, expected, descs = pretty_output_init(cpp_prep)
|
ta, res, ctr, expected, descs = pretty_output_init(cpp_prep)
|
||||||
with open(log_file, "a") as log:
|
with open(log_file, "a") as log:
|
||||||
generator = run_proverif(awk_prep)
|
generator = run_proverif(awk_prep, log_file)
|
||||||
for line in generator:
|
for line in generator:
|
||||||
log.write(line)
|
|
||||||
# parse-result-line:
|
# parse-result-line:
|
||||||
match = pkgs.re.search(r"^RESULT .* \b(true|false)\b\.$", line)
|
match = pkgs.re.search(r"^RESULT .* \b(true|false)\b\.$", line)
|
||||||
if match:
|
if match:
|
||||||
|
|||||||
Reference in New Issue
Block a user