Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add toggle for malicious security #84

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions server/app/query/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ function IPAForm({
const [commitSpecifier, setCommitSpecifier] = useState<CommitSpecifier>(
CommitSpecifier.BRANCH,
);
const [maliciousSecurityEnabled, setMaliciousSecurityEnabled] =
useState(true);
const [stallDetectionEnabled, setStallDetectionEnabled] = useState(true);
const [multiThreadingEnabled, setMultiThreadingEnabled] = useState(true);
const [disableMetricsEnabled, setDisableMetricsEnabled] = useState(false);
Expand Down Expand Up @@ -358,6 +360,33 @@ function IPAForm({
options={["compact", "descriptive"]}
defaultValue="compact"
/>
<div className="items-center pt-4">
<div className="block text-sm font-medium leading-6 text-gray-900">
Malicious Security
</div>
<div className="block pt-1 text-sm font-medium leading-6 text-gray-900">
<Switch
checked={maliciousSecurityEnabled}
onChange={setMaliciousSecurityEnabled}
className={`${
maliciousSecurityEnabled ? "bg-blue-600" : "bg-gray-200"
} relative inline-flex size-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2`}
>
<span
className={`${
maliciousSecurityEnabled ? "translate-x-6" : "translate-x-1"
} inline-block size-4 rounded-full bg-white transition-transform`}
/>
</Switch>
{/* Hidden input to ensure the field is always included in the form data */}
<input
type="hidden"
name="malicious_security"
value={maliciousSecurityEnabled.toString()}
/>
</div>
</div>

<div className="items-center pt-4">
<div className="block text-sm font-medium leading-6 text-gray-900">
Stall detection
Expand Down
10 changes: 9 additions & 1 deletion sidecar/app/query/ipa.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ class IPACoordinatorStartStep(LoggerOutputCommandStep):
max_breakdown_key: int
max_trigger_value: int
per_user_credit_cap: int
malicious_security: bool
status: ClassVar[Status] = Status.IN_PROGRESS

@classmethod
Expand All @@ -312,13 +313,19 @@ def build_from_query(cls, query: IPACoordinatorQuery):
max_breakdown_key=query.max_breakdown_key,
max_trigger_value=query.max_trigger_value,
per_user_credit_cap=query.per_user_credit_cap,
malicious_security=query.malicious_security,
logger=query.logger,
)

def build_command(self) -> LoggerOutputCommand:
query_type = (
"malicious-oprf-ipa-test"
if self.malicious_security
else "semi-honest-oprf-ipa-test"
)
return LoggerOutputCommand(
cmd=f"{self.report_collector_binary_path} --network {self.network_config} "
f"--input-file {self.test_data_path} semi-honest-oprf-ipa-test "
f"--input-file {self.test_data_path} {query_type} "
f"--max-breakdown-key {self.max_breakdown_key} "
f"--per-user-credit-cap {self.per_user_credit_cap} --plaintext-match-keys ",
logger=self.logger,
Expand All @@ -332,6 +339,7 @@ class IPACoordinatorQuery(IPAQuery):
max_breakdown_key: int
max_trigger_value: int
per_user_credit_cap: int
malicious_security: bool

step_classes: ClassVar[list[type[Step]]] = [
IPACloneStep,
Expand Down
2 changes: 2 additions & 0 deletions sidecar/app/routes/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def start_ipa_query(
max_breakdown_key: Annotated[int, Form()],
max_trigger_value: Annotated[int, Form()],
per_user_credit_cap: Annotated[int, Form()],
malicious_security: Annotated[bool, Form()],
background_tasks: BackgroundTasks,
request: Request,
):
Expand Down Expand Up @@ -191,6 +192,7 @@ def start_ipa_query(
max_breakdown_key=max_breakdown_key,
max_trigger_value=max_trigger_value,
per_user_credit_cap=per_user_credit_cap,
malicious_security=malicious_security,
)

background_tasks.add_task(query_manager.run_query, query)
Expand Down
2 changes: 2 additions & 0 deletions sidecar/tests/app/routes/test_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def test_start_ipa_query(mock_role):
"max_breakdown_key": 16,
"max_trigger_value": 10,
"per_user_credit_cap": 5,
"malicious_security": True,
},
)
assert response.status_code == 200
Expand All @@ -128,6 +129,7 @@ def test_start_ipa_query_as_helper(mock_role):
"max_breakdown_key": 16,
"max_trigger_value": 10,
"per_user_credit_cap": 5,
"malicious_security": True,
},
)

Expand Down
Loading