Make using insecure connections opt-in (#1309)

* add insecure url checks

* rename variables

* add feature flags to expose Url properly

* fix test compile error

* fix feature errors

* remove comment

* add url crate and use it for url parsing

* fix compile errors

* satisfy the holy clippy

* fix typos and host loopback

* macro attribute, provide validation function in utils

* fix expected output of ui tests

* remove the success case for --allow-insecure because we cannot establish ws:// connection at the moment.
This commit is contained in:
Tadeo Hepperle
2024-01-09 18:18:23 +01:00
committed by GitHub
parent 5b35a9f849
commit 7f714cbcb9
22 changed files with 562 additions and 413 deletions
+7 -1
View File
@@ -5,7 +5,7 @@ use frame_metadata::RuntimeMetadataPrefixed;
use std::collections::HashMap;
use std::hash::Hash;
use crate::utils::FileOrUrl;
use crate::utils::{validate_url_security, FileOrUrl};
use color_eyre::owo_colors::OwoColorize;
use scale_info::form::PortableForm;
@@ -29,9 +29,15 @@ pub struct Opts {
metadata_or_url_1: FileOrUrl,
/// metadata file or node URL
metadata_or_url_2: FileOrUrl,
/// Allow insecure URLs e.g. URLs starting with ws:// or http:// without SSL encryption
#[clap(long, short)]
allow_insecure: bool,
}
pub async fn run(opts: Opts, output: &mut impl std::io::Write) -> color_eyre::Result<()> {
validate_url_security(opts.metadata_or_url_1.url.as_ref(), opts.allow_insecure)?;
validate_url_security(opts.metadata_or_url_2.url.as_ref(), opts.allow_insecure)?;
let (entry_1_metadata, entry_2_metadata) = get_metadata(&opts).await?;
let metadata_diff = MetadataDiff::construct(&entry_1_metadata, &entry_2_metadata);