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

Moved request validation before early-exit of extension requests. #602

Merged
merged 4 commits into from
Aug 19, 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
2 changes: 1 addition & 1 deletion .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main", "1.11.rc" ]
branches: [ "main", "1.11.rc", "1.12.rc" ]

env:
CARGO_TERM_COLOR: always
Expand Down
55 changes: 28 additions & 27 deletions core/main/src/firebolt/firebolt_gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,38 +197,39 @@ impl FireboltGateway {

tokio::spawn(async move {
let start = Utc::now().timestamp_millis();
let result = if extn_request {
// extn protocol means its an internal Ripple request skip permissions.
Ok(())
} else {
// Validate incoming request parameters.
if let Err(error_string) = validate_request(open_rpc_state, &request_c) {
let now = Utc::now().timestamp_millis();

RpcRouter::log_rdk_telemetry_message(
&request.ctx.app_id,
&request.method,
JSON_RPC_STANDARD_ERROR_INVALID_PARAMS,
now - start,
);
// Validate incoming request parameters.
if let Err(error_string) = validate_request(open_rpc_state, &request_c) {
let now = Utc::now().timestamp_millis();

TelemetryBuilder::stop_and_send_firebolt_metrics_timer(
&platform_state.clone(),
metrics_timer,
format!("{}", JSON_RPC_STANDARD_ERROR_INVALID_PARAMS),
)
.await;
RpcRouter::log_rdk_telemetry_message(
&request.ctx.app_id,
&request.method,
JSON_RPC_STANDARD_ERROR_INVALID_PARAMS,
now - start,
);

let json_rpc_error = JsonRpcError {
code: JSON_RPC_STANDARD_ERROR_INVALID_PARAMS,
message: error_string,
data: None,
};
TelemetryBuilder::stop_and_send_firebolt_metrics_timer(
&platform_state.clone(),
metrics_timer,
format!("{}", JSON_RPC_STANDARD_ERROR_INVALID_PARAMS),
)
.await;

send_json_rpc_error(&platform_state, &request, json_rpc_error).await;
return;
}
let json_rpc_error = JsonRpcError {
code: JSON_RPC_STANDARD_ERROR_INVALID_PARAMS,
message: error_string,
data: None,
};

send_json_rpc_error(&platform_state, &request, json_rpc_error).await;
return;
}

let result = if extn_request {
// extn protocol means its an internal Ripple request skip permissions.
Ok(())
} else {
FireboltGatekeeper::gate(platform_state.clone(), request_c.clone()).await
};

Expand Down
2 changes: 2 additions & 0 deletions core/sdk/src/api/firebolt/fb_advertising.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ pub struct AdConfig {
#[serde(default)]
pub environment: Environment,
// COPPA stands for Children's Online Privacy Protection Act.
#[serde(skip_serializing_if = "Option::is_none")]
pub coppa: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub authentication_entity: Option<String>,
}

Expand Down
Loading