Jormungandr: Jormungandr configuration does not check unknown fields

Created on 6 Sep 2019  路  3Comments  路  Source: input-output-hk/jormungandr

Describe the bug
Jormungandr configuration is not validated if we add some unknown fields

Mandatory Information

  1. jcli --full-version output:
    jcli 0.3.3 (master-dd038ef, release, windows [x86_64]) - [rustc 1.36.0 (a53f9df32 2019-07-03)]
  2. jormungandr --full-version output:
    jormungandr 0.3.3 (master-dd038ef, release, windows [x86_64]) - [rustc 1.36.0 (a53f9df32 2019-07-03)]

To Reproduce
Steps to reproduce the behavior:

  1. Prepare configuration file like below:
---

rest:
  listen: "127.0.0.1:8001"
p2p:
  public_address: /ip4/127.0.0.1/tcp/9001
  public_publig: addnkjnkjnknkjnkj
  unknown field: value
  id: 43594425551286079828071352457839944954
  trusted_peers: []
unknown:
    something: a
  1. Start jormungandr with above configuration
  2. Jormungandr starts successfully

Expected behavior
Should return error that config has some unknown fields

bug enhancement good first issue A-jormungandr

All 3 comments

Great. thanks for spotting this one.

there is a very simple way to fix it and it's documented here: https://serde.rs/container-attrs.html#deny_unknown_fields

The fix is done via updating https://github.com/input-output-hk/jormungandr/blob/37391147856220c0b338a1a2f36fc06bec9cc3e2/jormungandr/src/settings/start/config.rs#L12-L13 and every associated types that implments Serialize/Deserialize and to have that attribute added

#[derive(Debug, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Config {
    pub secret_files: Option<Vec<PathBuf>>,

    // ....

    pub explorer: Option<Explorer>,
}

Also if the one who pick this issue can remove this field:

https://github.com/input-output-hk/jormungandr/blob/37391147856220c0b338a1a2f36fc06bec9cc3e2/jormungandr/src/settings/start/config.rs#L60-L62

It is not used anymore since #757

I can get this one if no one else already started working on it.

Was this page helpful?
0 / 5 - 0 ratings