Spaces:
Running
Running
Commit
·
c1f713e
1
Parent(s):
7976155
Show no mitigations status
Browse files- app.py +2 -1
- executor.py +6 -2
app.py
CHANGED
|
@@ -79,6 +79,7 @@ class UI:
|
|
| 79 |
"""<h2> Mitigations </h2>
|
| 80 |
Select a potential risk to determine possible mitigations. """
|
| 81 |
)
|
|
|
|
| 82 |
self.mitigations = gr.DataFrame(label=None, visible=False)
|
| 83 |
|
| 84 |
gr.Markdown("---")
|
|
@@ -115,7 +116,7 @@ class UI:
|
|
| 115 |
fn=mitigations,
|
| 116 |
inputs=[self.assessed_risks, self.taxonomy],
|
| 117 |
# NOTETOSELF: Intent based risk is stored in self.risk (if needed)
|
| 118 |
-
outputs=[self.assessed_risk_definition, self.relatedrisks, self.mitigations]
|
| 119 |
)
|
| 120 |
return demo
|
| 121 |
|
|
|
|
| 79 |
"""<h2> Mitigations </h2>
|
| 80 |
Select a potential risk to determine possible mitigations. """
|
| 81 |
)
|
| 82 |
+
self.mitigations_text = gr.Markdown()
|
| 83 |
self.mitigations = gr.DataFrame(label=None, visible=False)
|
| 84 |
|
| 85 |
gr.Markdown("---")
|
|
|
|
| 116 |
fn=mitigations,
|
| 117 |
inputs=[self.assessed_risks, self.taxonomy],
|
| 118 |
# NOTETOSELF: Intent based risk is stored in self.risk (if needed)
|
| 119 |
+
outputs=[self.assessed_risk_definition, self.relatedrisks, self.mitigations, self.mitigations_text]
|
| 120 |
)
|
| 121 |
return demo
|
| 122 |
|
executor.py
CHANGED
|
@@ -56,7 +56,7 @@ def risk_identifier(usecase: str,
|
|
| 56 |
|
| 57 |
|
| 58 |
@lru_cache
|
| 59 |
-
def mitigations(riskid: str, taxonomy: str) -> tuple[gr.Markdown, gr.Dataset, gr.DataFrame]:
|
| 60 |
"""
|
| 61 |
For a specific risk (riskid), returns
|
| 62 |
(a) a risk description
|
|
@@ -104,13 +104,17 @@ def mitigations(riskid: str, taxonomy: str) -> tuple[gr.Markdown, gr.Dataset, gr
|
|
| 104 |
asamples = None
|
| 105 |
asample_labels = None
|
| 106 |
mitdf = pd.DataFrame()
|
|
|
|
| 107 |
else:
|
| 108 |
alabel = f"Mitigation actions related to risk {riskid}."
|
| 109 |
asamples = action_ids
|
| 110 |
asample_labels = [ran.get_action_by_id(i).description for i in asamples] # type: ignore
|
| 111 |
asample_name = [ran.get_action_by_id(i).name for i in asamples] #type: ignore
|
| 112 |
mitdf = pd.DataFrame({"Mitigation": asample_name, "Description": asample_labels})
|
|
|
|
|
|
|
| 113 |
|
| 114 |
return (gr.Markdown(risk_sec),
|
| 115 |
gr.Dataset(samples=samples, label=label, sample_labels=sample_labels, visible=True),
|
| 116 |
-
gr.DataFrame(mitdf, wrap=True, show_copy_button=True, show_search="search", label=alabel, visible=True)
|
|
|
|
|
|
| 56 |
|
| 57 |
|
| 58 |
@lru_cache
|
| 59 |
+
def mitigations(riskid: str, taxonomy: str) -> tuple[gr.Markdown, gr.Dataset, gr.DataFrame, gr.Markdown]:
|
| 60 |
"""
|
| 61 |
For a specific risk (riskid), returns
|
| 62 |
(a) a risk description
|
|
|
|
| 104 |
asamples = None
|
| 105 |
asample_labels = None
|
| 106 |
mitdf = pd.DataFrame()
|
| 107 |
+
|
| 108 |
else:
|
| 109 |
alabel = f"Mitigation actions related to risk {riskid}."
|
| 110 |
asamples = action_ids
|
| 111 |
asample_labels = [ran.get_action_by_id(i).description for i in asamples] # type: ignore
|
| 112 |
asample_name = [ran.get_action_by_id(i).name for i in asamples] #type: ignore
|
| 113 |
mitdf = pd.DataFrame({"Mitigation": asample_name, "Description": asample_labels})
|
| 114 |
+
|
| 115 |
+
status = gr.Markdown(" ") if len(mitdf) > 0 else gr.Markdown("No mitigations found.")
|
| 116 |
|
| 117 |
return (gr.Markdown(risk_sec),
|
| 118 |
gr.Dataset(samples=samples, label=label, sample_labels=sample_labels, visible=True),
|
| 119 |
+
gr.DataFrame(mitdf, wrap=True, show_copy_button=True, show_search="search", label=alabel, visible=True),
|
| 120 |
+
status)
|