Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,71 +1,52 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
-
problematic_url = "https://huggingface.co/Norod78/Flux_1_Dev_LoRA_Paper-Cutout-Style/resolve/main/08a19840b6214b76b0607b2f9d5a7e28_63159b9d98124c008efb1d36446a615c.png"
|
6 |
-
|
7 |
-
# Sample data with image URLs (similar to loras_state)
|
8 |
-
sample_data = [
|
9 |
{
|
10 |
-
"
|
11 |
-
"
|
12 |
-
"repo": "
|
|
|
13 |
}
|
14 |
]
|
15 |
|
16 |
-
def
|
17 |
-
"""
|
18 |
-
|
19 |
-
but the error occurs before it even executes when gallery is in outputs.
|
20 |
-
"""
|
21 |
-
print("Function was called!") # This should appear in logs but doesn't
|
22 |
-
|
23 |
-
# Add a new item to state
|
24 |
-
new_item = {
|
25 |
-
"title": f"New Item: {text_input}",
|
26 |
-
"image": problematic_url, # This URL in the return value triggers SSRF
|
27 |
-
"repo": "new/repo"
|
28 |
-
}
|
29 |
-
state_data.append(new_item)
|
30 |
|
31 |
-
|
32 |
-
|
33 |
|
34 |
-
|
35 |
-
|
|
|
|
|
36 |
|
37 |
-
# Create the interface
|
38 |
with gr.Blocks() as demo:
|
39 |
-
gr.Markdown("#
|
40 |
-
gr.Markdown("Click the button below. You should see an error about hostname validation.")
|
41 |
-
gr.Markdown("The error occurs when the function tries to return data that will update a gallery with HuggingFace URLs.")
|
42 |
-
|
43 |
-
# State containing URLs that trigger the issue
|
44 |
-
state_var = gr.State(sample_data)
|
45 |
|
46 |
-
|
47 |
-
text_input = gr.Textbox(label="Enter some text", value="test")
|
48 |
|
49 |
-
|
|
|
50 |
gallery = gr.Gallery(
|
51 |
-
|
52 |
-
|
53 |
-
columns=
|
54 |
)
|
55 |
|
56 |
-
|
57 |
-
output = gr.Textbox(label="Output")
|
58 |
|
59 |
-
|
60 |
-
button = gr.Button("Add item - this will fail")
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
inputs=[text_input, state_var],
|
67 |
-
outputs=[output, state_var, gallery] # Including gallery in outputs triggers the error
|
68 |
)
|
69 |
|
70 |
if __name__ == "__main__":
|
|
|
|
|
71 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import json
|
3 |
|
4 |
+
# Sample data with HuggingFace image URLs that redirect to cas-bridge-direct.xethub.hf.co
|
5 |
+
sample_loras = [
|
|
|
|
|
|
|
|
|
6 |
{
|
7 |
+
"image": "https://huggingface.co/Norod78/Flux_1_Dev_LoRA_Paper-Cutout-Style/resolve/main/08a19840b6214b76b0607b2f9d5a7e28_63159b9d98124c008efb1d36446a615c.png",
|
8 |
+
"title": "Paper Cutout",
|
9 |
+
"repo": "Norod78/Flux_1_Dev_LoRA_Paper-Cutout-Style",
|
10 |
+
"trigger_word": ", Paper Cutout Style"
|
11 |
}
|
12 |
]
|
13 |
|
14 |
+
def add_custom_lora_broken(custom_lora, selected_indices, current_loras, gallery):
|
15 |
+
"""This version breaks because it passes current_loras (containing HF URLs) as function input"""
|
16 |
+
print("Starting to load a custom LoRA...") # This won't print due to preprocessing error
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
if custom_lora:
|
19 |
+
pass
|
20 |
|
21 |
+
return current_loras, gr.update(), gr.update(), gr.update(), selected_indices
|
22 |
+
|
23 |
+
# Initialize state with URLs that will cause SSRF validation issues
|
24 |
+
loras_state = gr.State(sample_loras)
|
25 |
|
|
|
26 |
with gr.Blocks() as demo:
|
27 |
+
gr.Markdown("# SSRF Validation Bug Reproduction")
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
selected_indices = gr.State([])
|
|
|
30 |
|
31 |
+
custom_lora_input = gr.Textbox(label="Custom LoRA", placeholder="Enter custom LoRA")
|
32 |
+
|
33 |
gallery = gr.Gallery(
|
34 |
+
[(item["image"], item["title"]) for item in sample_loras],
|
35 |
+
label="LoRA Gallery",
|
36 |
+
columns=2
|
37 |
)
|
38 |
|
39 |
+
broken_button = gr.Button("Add Custom LoRA (Broken - passes state with URLs)")
|
|
|
40 |
|
41 |
+
error_display = gr.Textbox(label="Error/Success", interactive=False)
|
|
|
42 |
|
43 |
+
broken_button.click(
|
44 |
+
add_custom_lora_broken,
|
45 |
+
inputs=[custom_lora_input, selected_indices, loras_state, gallery], # ← loras_state causes SSRF error
|
46 |
+
outputs=[loras_state, gallery, error_display, custom_lora_input, selected_indices]
|
|
|
|
|
47 |
)
|
48 |
|
49 |
if __name__ == "__main__":
|
50 |
+
# Set global variable for working version
|
51 |
+
loras = sample_loras
|
52 |
demo.launch()
|