Skip to content

Commit

Permalink
Moved request validation before early-exit of extension requests. (#602)
Browse files Browse the repository at this point in the history
  • Loading branch information
pahearn73 authored Aug 19, 2024
1 parent 5e52350 commit 69598c0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
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

0 comments on commit 69598c0

Please sign in to comment.