
Research
NPM targeted by malware campaign mimicking familiar library names
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
gradio-sandboxcomponent
Advanced tools
gradio_sandboxcomponent
Gradio library for easily interacting with remote sandbox.
pip install gradio_sandboxcomponent
from typing import Any
import gradio as gr
from gradio_sandboxcomponent import SandboxComponent
example = SandboxComponent().example_value()
with gr.Blocks() as demo:
with gr.Tab("Sandbox Demo"):
with gr.Row():
gr.Markdown("## Sandbox")
with gr.Row():
sandboxUrl = gr.Textbox(
label="Sandbox URL",
value='https://www.gradio.app/',
placeholder="Enter sandbox URL",
lines=1,
show_label=True,
)
sandboxInteractions = gr.Textbox(
label="Sandbox Interactions",
value='[]',
placeholder="Enter sandbox interactions",
lines=1,
show_label=True,
)
with gr.Row():
sandbox = SandboxComponent(
label="Sandbox Example",
value=("https://www.gradio.app/", True, []),
show_label=True)
def update_outputs(sandboxData: tuple[str, list[Any]]):
sandboxUrl, _, sandboxInteractions = sandboxData
print(
"UPDATING",
sandboxData
)
return sandboxUrl, str(sandboxInteractions)
sandbox.change(
update_outputs,
inputs=[sandbox],
outputs=[sandboxUrl, sandboxInteractions]
)
def update_sandbox_url(url: str):
sandbox.value = (url, True, [])
return sandbox.value
sandboxUrl.change(
update_sandbox_url,
inputs=[sandboxUrl],
outputs=[sandbox]
)
if __name__ == "__main__":
demo.launch()
SandboxComponent
name | type | default | description |
---|---|---|---|
value |
| None | url string and interactions. |
label |
| None | the label for this component, displayed above the component if `show_label` is `True` and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component corresponds to. |
every |
| None | Continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer. |
inputs |
| None | Components that are used as inputs to calculate `value` if `value` is a function (has no effect otherwise). `value` is recalculated any time the inputs change. |
show_label |
| None | if True, will display label. |
scale |
| None | relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True. |
min_width |
| 160 | minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first. |
interactive |
| None | if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output. |
visible |
| True | If False, component will be hidden. |
elem_id |
| None | None |
elem_classes |
| None | An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles. |
render |
| True | If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later. |
key |
| None | if assigned, will be used to assume identity across a re-render. Components that have the same key across a re-render will have their value preserved. |
name | description |
---|---|
change | Triggered when the value of the SandboxComponent changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See .input() for a listener that is only triggered by user input. |
input | This listener is triggered when the user changes the value of the SandboxComponent. |
submit | This listener is triggered when the user presses the Enter key while the SandboxComponent is focused. |
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
The code snippet below is accurate in cases where the component is used as both an input and an output.
def predict(
value: tuple[str, bool, list[typing.Any]] | None
) -> tuple[str, bool, list[typing.Any]] | dict | None:
return value
FAQs
Gradio library for easily interacting with remote sandbox.
We found that gradio-sandboxcomponent demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Research
Socket's research uncovers three dangerous Go modules that contain obfuscated disk-wiping malware, threatening complete data loss.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.