Spaces:
Sleeping
Sleeping
Commit ·
f05dfe4
1
Parent(s): 16fc4f3
Lay out the inputs in two columns
Browse filesChoices and the Run button sit on the left; uploads, C source and the
decompiler configuration sit on the right. The right column hides when
an artifact has nothing to show there.
125 unmodified lines126127128129130131132133134134 unmodified lines269270271272273274275276277278279280281282283284285286287288289290291292293294125 unmodified linesdef mode_controls(artifact, choice):if ARTIFACTS[artifact][2] is not sefm_stages:return gr.update(visible=choice == UPLOAD), *[gr.update(visible=False)] * 3, gr.update()config = {EXAMPLE: sefm.example_config, SOURCE: lambda: sefm.C_EXAMPLE_CONFIG, UPLOAD: lambda: sefm.CONFIG_TEMPLATE}[choice]()return (gr.update(visible=choice == UPLOAD), gr.update(visible=choice == SOURCE, value=sefm.C_EXAMPLE),gr.update(visible=choice == SOURCE, value=sefm.DEFAULT_CFLAGS),gr.update(visible=True, open=choice == UPLOAD), gr.update(value=config))134 unmodified lines) as demo:gr.Markdown("# FoxDec research artifacts\nAnalyze a Linux x86-64 binary, inspect the generated assembly and graphs, or verify a lifting certificate.")first = next(iter(ARTIFACTS))artifact = gr.Radio(list(ARTIFACTS), value=first, label="Artifact")about = gr.Markdown(ARTIFACTS[first][3])mode = gr.Radio(input_choices(first), value=EXAMPLE, label="Input")with gr.Column(visible=False) as upload_inputs:upload = gr.File(label="Linux x86-64 ELF binary", type="filepath")addresses = gr.Textbox(label="Entry addresses (optional)", placeholder="0x401000", visible=False)source = gr.Code(label="C source (compiled with gcc, never run)", language="c", value=sefm.C_EXAMPLE, visible=False)cflags = gr.Textbox(label="Compiler options", value=sefm.DEFAULT_CFLAGS, visible=False,info="Optimization, code generation, warning and macro options. The paper’s tool expects x86-64 and no PIE.")with gr.Accordion("Decompiler configuration", open=False) as config_panel:config = gr.Textbox(show_label=False, lines=16, max_lines=16, show_copy_button=True,value=sefm.example_config(),info="Functions to decompile, their argument registers, and the C preamble.")run = gr.Button("Run analysis", variant="primary", size="lg")status = gr.Textbox(label="Status", lines=4, max_lines=12, interactive=False, visible=False)results = gr.HTML(value="<p>Run an analysis to see its results here.</p>")with gr.Accordion("Artifact catalog", open=False):gr.Markdown(Path(__file__).with_name("catalog.md").read_text())mode_outputs = [upload_inputs, source, cflags, config_panel, config]artifact.input(input_controls, artifact, [about, mode, upload, addresses, *mode_outputs], queue=False, api_name=False)mode.input(mode_controls, [artifact, mode], mode_outputs, queue=False, api_name=False)outputs = [status, results, run]125 unmodified lines126127128129130131132133134134 unmodified lines269270271272273274275276277278279280281282283284285286287288289290291292293294295296297125 unmodified linesdef mode_controls(artifact, choice):if ARTIFACTS[artifact][2] is not sefm_stages:return *[gr.update(visible=choice == UPLOAD)] * 2, *[gr.update(visible=False)] * 3, gr.update()config = {EXAMPLE: sefm.example_config, SOURCE: lambda: sefm.C_EXAMPLE_CONFIG, UPLOAD: lambda: sefm.CONFIG_TEMPLATE}[choice]()return (gr.update(visible=True), gr.update(visible=choice == UPLOAD), gr.update(visible=choice == SOURCE, value=sefm.C_EXAMPLE),gr.update(visible=choice == SOURCE, value=sefm.DEFAULT_CFLAGS),gr.update(visible=True, open=choice == UPLOAD), gr.update(value=config))134 unmodified lines) as demo:gr.Markdown("# FoxDec research artifacts\nAnalyze a Linux x86-64 binary, inspect the generated assembly and graphs, or verify a lifting certificate.")first = next(iter(ARTIFACTS))with gr.Row(equal_height=False):with gr.Column(scale=1, min_width=320):artifact = gr.Radio(list(ARTIFACTS), value=first, label="Artifact")about = gr.Markdown(ARTIFACTS[first][3])mode = gr.Radio(input_choices(first), value=EXAMPLE, label="Input")run = gr.Button("Run analysis", variant="primary", size="lg")status = gr.Textbox(label="Status", lines=4, max_lines=12, interactive=False, visible=False)with gr.Column(scale=1, min_width=320) as inputs_column:with gr.Column(visible=False) as upload_inputs:upload = gr.File(label="Linux x86-64 ELF binary", type="filepath")addresses = gr.Textbox(label="Entry addresses (optional)", placeholder="0x401000", visible=False)source = gr.Code(label="C source (compiled with gcc, never run)", language="c", value=sefm.C_EXAMPLE, visible=False)cflags = gr.Textbox(label="Compiler options", value=sefm.DEFAULT_CFLAGS, visible=False,info="Optimization, code generation, warning and macro options. The paper’s tool expects x86-64 and no PIE.")with gr.Accordion("Decompiler configuration", open=False) as config_panel:config = gr.Textbox(show_label=False, lines=16, max_lines=16, show_copy_button=True,value=sefm.example_config(),info="Functions to decompile, their argument registers, and the C preamble.")results = gr.HTML(value="<p>Run an analysis to see its results here.</p>")with gr.Accordion("Artifact catalog", open=False):gr.Markdown(Path(__file__).with_name("catalog.md").read_text())mode_outputs = [inputs_column, upload_inputs, source, cflags, config_panel, config]artifact.input(input_controls, artifact, [about, mode, upload, addresses, *mode_outputs], queue=False, api_name=False)mode.input(mode_controls, [artifact, mode], mode_outputs, queue=False, api_name=False)outputs = [status, results, run]
app.py+21-18