Skip to content

Commit 18edf22

Browse files
amilzgithub-actions
andauthored
chore: (PRO-275) Set FeePayerPolicy defaults to false (#217)
* chore: Set FeePayerPolicy defaults to false Changed all FeePayerPolicy default values from true to false, ensuring explicit policy configuration is required for fee payer actions. Updated related tests and documentation to reflect the new defaults. * Update coverage badge [skip ci] --------- Co-authored-by: github-actions <github-actions@github.com>
1 parent c2843ac commit 18edf22

File tree

5 files changed

+41
-40
lines changed

5 files changed

+41
-40
lines changed

.github/badges/coverage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"schemaVersion": 1, "label": "coverage", "message": "85.8%", "color": "green"}
1+
{"schemaVersion": 1, "label": "coverage", "message": "85.6%", "color": "green"}

crates/lib/src/config.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl ValidationConfig {
134134
}
135135
}
136136

137-
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
137+
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, Default)]
138138
pub struct FeePayerPolicy {
139139
pub allow_sol_transfers: bool,
140140
pub allow_spl_transfers: bool,
@@ -145,20 +145,6 @@ pub struct FeePayerPolicy {
145145
pub allow_approve: bool,
146146
}
147147

148-
impl Default for FeePayerPolicy {
149-
fn default() -> Self {
150-
Self {
151-
allow_sol_transfers: true,
152-
allow_spl_transfers: true,
153-
allow_token2022_transfers: true,
154-
allow_assign: true,
155-
allow_burn: true,
156-
allow_close_account: true,
157-
allow_approve: true,
158-
}
159-
}
160-
}
161-
162148
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
163149
pub struct Token2022Config {
164150
pub blocked_mint_extensions: Vec<String>,

crates/lib/src/rpc_server/method/get_config.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ mod tests {
8989
assert_eq!(response.validation_config.price_source, crate::oracle::PriceSource::Mock);
9090

9191
// Assert FeePayerPolicy defaults
92-
assert!(response.validation_config.fee_payer_policy.allow_sol_transfers);
93-
assert!(response.validation_config.fee_payer_policy.allow_spl_transfers);
94-
assert!(response.validation_config.fee_payer_policy.allow_token2022_transfers);
95-
assert!(response.validation_config.fee_payer_policy.allow_assign);
96-
assert!(response.validation_config.fee_payer_policy.allow_burn);
97-
assert!(response.validation_config.fee_payer_policy.allow_close_account);
98-
assert!(response.validation_config.fee_payer_policy.allow_approve);
92+
assert!(!response.validation_config.fee_payer_policy.allow_sol_transfers);
93+
assert!(!response.validation_config.fee_payer_policy.allow_spl_transfers);
94+
assert!(!response.validation_config.fee_payer_policy.allow_token2022_transfers);
95+
assert!(!response.validation_config.fee_payer_policy.allow_assign);
96+
assert!(!response.validation_config.fee_payer_policy.allow_burn);
97+
assert!(!response.validation_config.fee_payer_policy.allow_close_account);
98+
assert!(!response.validation_config.fee_payer_policy.allow_approve);
9999

100100
// Assert PriceConfig default (check margin value)
101101
match response.validation_config.price.model {

crates/lib/src/validator/transaction_validator.rs

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,11 @@ mod tests {
566566
let fee_payer = Pubkey::new_unique();
567567
let recipient = Pubkey::new_unique();
568568

569-
// Test with allow_sol_transfers = true (default)
570-
setup_default_config();
569+
// Test with allow_sol_transfers = true
570+
setup_config_with_policy(FeePayerPolicy {
571+
allow_sol_transfers: true,
572+
..Default::default()
573+
});
571574

572575
let validator = TransactionValidator::new(fee_payer).unwrap();
573576

@@ -597,8 +600,8 @@ mod tests {
597600
let fee_payer = Pubkey::new_unique();
598601
let new_owner = Pubkey::new_unique();
599602

600-
// Test with allow_assign = true (default)
601-
setup_default_config();
603+
// Test with allow_assign = true
604+
setup_config_with_policy(FeePayerPolicy { allow_assign: true, ..Default::default() });
602605

603606
let validator = TransactionValidator::new(fee_payer).unwrap();
604607

@@ -626,8 +629,11 @@ mod tests {
626629
let fee_payer_token_account = Pubkey::new_unique();
627630
let recipient_token_account = Pubkey::new_unique();
628631

629-
// Test with allow_spl_transfers = true (default)
630-
setup_spl_token_config();
632+
// Test with allow_spl_transfers = true
633+
setup_spl_config_with_policy(FeePayerPolicy {
634+
allow_spl_transfers: true,
635+
..Default::default()
636+
});
631637

632638
let validator = TransactionValidator::new(fee_payer).unwrap();
633639

@@ -693,8 +699,11 @@ mod tests {
693699
let recipient_token_account = Pubkey::new_unique();
694700
let mint = Pubkey::new_unique();
695701

696-
// Test with allow_token2022_transfers = true (default)
697-
setup_token2022_config();
702+
// Test with allow_token2022_transfers = true
703+
setup_token2022_config_with_policy(FeePayerPolicy {
704+
allow_token2022_transfers: true,
705+
..Default::default()
706+
});
698707

699708
let validator = TransactionValidator::new(fee_payer).unwrap();
700709

@@ -888,8 +897,8 @@ mod tests {
888897
let fee_payer_token_account = Pubkey::new_unique();
889898
let mint = Pubkey::new_unique();
890899

891-
// Test with allow_burn = true (default)
892-
setup_spl_token_config();
900+
// Test with allow_burn = true
901+
setup_spl_config_with_policy(FeePayerPolicy { allow_burn: true, ..Default::default() });
893902

894903
let validator = TransactionValidator::new(fee_payer).unwrap();
895904

@@ -955,8 +964,11 @@ mod tests {
955964
let fee_payer_token_account = Pubkey::new_unique();
956965
let destination = Pubkey::new_unique();
957966

958-
// Test with allow_close_account = true (default)
959-
setup_spl_token_config();
967+
// Test with allow_close_account = true
968+
setup_spl_config_with_policy(FeePayerPolicy {
969+
allow_close_account: true,
970+
..Default::default()
971+
});
960972

961973
let validator = TransactionValidator::new(fee_payer).unwrap();
962974

@@ -1005,8 +1017,8 @@ mod tests {
10051017
let fee_payer_token_account = Pubkey::new_unique();
10061018
let delegate = Pubkey::new_unique();
10071019

1008-
// Test with allow_approve = true (default)
1009-
setup_spl_token_config();
1020+
// Test with allow_approve = true
1021+
setup_spl_config_with_policy(FeePayerPolicy { allow_approve: true, ..Default::default() });
10101022

10111023
let validator = TransactionValidator::new(fee_payer).unwrap();
10121024

@@ -1136,8 +1148,11 @@ mod tests {
11361148
let fee_payer_token_account = Pubkey::new_unique();
11371149
let delegate = Pubkey::new_unique();
11381150

1139-
// Test with allow_approve = true (default)
1140-
setup_token2022_config();
1151+
// Test with allow_approve = true
1152+
setup_token2022_config_with_policy(FeePayerPolicy {
1153+
allow_approve: true,
1154+
..Default::default()
1155+
});
11411156

11421157
let validator = TransactionValidator::new(fee_payer).unwrap();
11431158

docs/operators/deploy/sample/kora.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ allowed_spl_paid_tokens = [
3737
disallowed_accounts = []
3838

3939
# Fee payer policy controls what actions the fee payer can perform
40-
# All default to true for backward compatibility
40+
# All default to false for security
4141
[validation.fee_payer_policy]
4242
allow_sol_transfers = true # Allow fee payer to be source in SOL transfers
4343
allow_spl_transfers = true # Allow fee payer to be source in SPL token transfers

0 commit comments

Comments
 (0)