netavark-1.13.0-2.fc42

List of Findings

Error: CLIPPY_WARNING: [#def1]
netavark-1.13.0-build/src/firewall/firewalld.rs:171:9: warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
#      |
#  171 | /         match setup_portfw.port_mappings {
#  172 | |             Some(ports) => {
#  173 | |                 for port in ports {
#  174 | |                     if !port.host_ip.is_empty() {
#  ...   |
#  189 | |             None => {}
#  190 | |         };
#      | |_________^
#      |
#      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
#      = note: `#[warn(clippy::single_match)]` on by default
#  help: try
#      |
#  171 ~         if let Some(ports) = setup_portfw.port_mappings {
#  172 +             for port in ports {
#  173 +                 if !port.host_ip.is_empty() {
#  174 +                     port_forwarding_rules
#  175 +                         .append(Value::new(make_port_tuple(port, &port.host_ip)))?;
#  176 +                 } else {
#  177 +                     if let Some(v4) = setup_portfw.container_ip_v4 {
#  178 +                         port_forwarding_rules
#  179 +                             .append(Value::new(make_port_tuple(port, &v4.to_string())))?;
#  180 +                     }
#  181 +                     if let Some(v6) = setup_portfw.container_ip_v6 {
#  182 +                         port_forwarding_rules
#  183 +                             .append(Value::new(make_port_tuple(port, &v6.to_string())))?;
#  184 +                     }
#  185 +                 }
#  186 +             }
#  187 ~         };
#      |

Error: CLIPPY_WARNING: [#def2]
netavark-1.13.0-build/src/firewall/varktables/types.rs:541:5: warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
#      |
#  541 | /     match pfwd.port_mappings {
#  542 | |         Some(ports) => {
#  543 | |             for i in ports {
#  544 | |                 let host_ip = if i.host_ip.is_empty() {
#  ...   |
#  644 | |         None => {}
#  645 | |     };
#      | |_____^
#      |
#      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
#  help: try
#      |
#  541 ~     if let Some(ports) = pfwd.port_mappings {
#  542 +         for i in ports {
#  543 +             let host_ip = if i.host_ip.is_empty() {
#  544 +                 None
#  545 +             } else {
#  546 +                 match i.host_ip.parse() {
#  547 +                     Ok(ip) => match ip {
#  548 +                         IpAddr::V4(v4) => {
#  549 +                             if is_ipv6 {
#  550 +                                 continue;
#  551 +                             }
#  552 +                             if !v4.is_unspecified() {
#  553 +                                 Some(IpAddr::V4(v4))
#  554 +                             } else {
#  555 +                                 None
#  556 +                             }
#  557 +                         }
#  558 +                         IpAddr::V6(v6) => {
#  559 +                             if !is_ipv6 {
#  560 +                                 continue;
#  561 +                             }
#  562 +                             if !v6.is_unspecified() {
#  563 +                                 Some(IpAddr::V6(v6))
#  564 +                             } else {
#  565 +                                 None
#  566 +                             }
#  567 +                         }
#  568 +                     },
#  569 +                     Err(_) => {
#  570 +                         return Err(NetavarkError::msg(format!(
#  571 +                             "invalid host ip \"{}\" provided for port {}",
#  572 +                             i.host_ip, i.host_port,
#  573 +                         )));
#  574 +                     }
#  575 +                 }
#  576 +             };
#  577 + 
#  578 +             // hostport dnat
#  579 +             let is_range = i.range > 1;
#  580 +             let mut host_port = i.host_port.to_string();
#  581 +             if is_range {
#  582 +                 host_port = format!("{}:{}", i.host_port, (i.host_port + (i.range - 1)))
#  583 +             }
#  584 +             netavark_hostport_dn_chain.build_rule(VarkRule::new(
#  585 +                 format!(
#  586 +                     // I'm leaving this commented code for now in the case
#  587 +                     // we need to revert.
#  588 +                     // "-j {} -p {} -m multiport --destination-ports {} {}",
#  589 +                     "-j {} -p {} --dport {} {}",
#  590 +                     network_dn_chain_name, i.protocol, &host_port, comment_dn_network_cid
#  591 +                 ),
#  592 +                 None,
#  593 +             ));
#  594 + 
#  595 +             let mut dn_setmark_rule_localhost = format!(
#  596 +                 "-j {} -s {} -p {} --dport {}",
#  597 +                 NETAVARK_HOSTPORT_SETMARK, network_address, i.protocol, &host_port
#  598 +             );
#  599 + 
#  600 +             let mut dn_setmark_rule_subnet = format!(
#  601 +                 "-j {} -s {} -p {} --dport {}",
#  602 +                 NETAVARK_HOSTPORT_SETMARK, localhost_ip, i.protocol, &host_port
#  603 +             );
#  604 + 
#  605 +             // if a destination ip address is provided, we need to alter
#  606 +             // the rule a bit
#  607 +             if let Some(host_ip) = host_ip {
#  608 +                 dn_setmark_rule_localhost = format!("{dn_setmark_rule_localhost} -d {host_ip}");
#  609 +                 dn_setmark_rule_subnet = format!("{dn_setmark_rule_subnet} -d {host_ip}");
#  610 +             }
#  611 + 
#  612 +             // dn container (the actual port usages)
#  613 +             netavark_hashed_dn_chain.build_rule(VarkRule::new(dn_setmark_rule_localhost, None));
#  614 + 
#  615 +             netavark_hashed_dn_chain.build_rule(VarkRule::new(dn_setmark_rule_subnet, None));
#  616 + 
#  617 +             let mut container_ip_value = container_ip.to_string();
#  618 +             if is_ipv6 {
#  619 +                 container_ip_value = format!("[{container_ip_value}]")
#  620 +             }
#  621 +             let mut container_port = i.container_port.to_string();
#  622 +             if is_range {
#  623 +                 container_port = format!(
#  624 +                     "{}-{}/{}",
#  625 +                     i.container_port,
#  626 +                     (i.container_port + (i.range - 1)),
#  627 +                     i.host_port
#  628 +                 );
#  629 +             }
#  630 +             let mut dnat_rule = format!(
#  631 +                 "-j {} -p {} --to-destination {}:{} --destination-port {}",
#  632 +                 DNAT, i.protocol, container_ip_value, container_port, &host_port
#  633 +             );
#  634 + 
#  635 +             // if a destination ip address is provided, we need to alter
#  636 +             // the rule a bit
#  637 +             if let Some(host_ip) = host_ip {
#  638 +                 dnat_rule = format!("{dnat_rule} -d {host_ip}")
#  639 +             }
#  640 +             netavark_hashed_dn_chain.build_rule(VarkRule::new(dnat_rule, None));
#  641 +         }
#  642 ~     };
#      |

Error: CLIPPY_WARNING: [#def3]
netavark-1.13.0-build/src/network/bridge.rs:183:13: warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
#      |
#  183 | /             match &self.info.per_network_opts.aliases {
#  184 | |                 Some(n) => {
#  185 | |                     names.extend(n.clone());
#  186 | |                 }
#  187 | |                 None => {}
#  188 | |             }
#      | |_____________^
#      |
#      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
#  help: try
#      |
#  183 ~             if let Some(n) = &self.info.per_network_opts.aliases {
#  184 +                 names.extend(n.clone());
#  185 +             }
#      |

Scan Properties

analyzer-version-clippy1.82.0
analyzer-version-cppcheck2.16.0
analyzer-version-gcc14.2.1
analyzer-version-gcc-analyzer15.0.0
analyzer-version-shellcheck0.10.0
analyzer-version-unicontrol0.0.2
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-91.us-west-2.compute.internal
mock-configfedora-rawhide-gcc-latest-x86_64
project-namenetavark-1.13.0-2.fc42
store-results-to/tmp/tmpe7ayunmt/netavark-1.13.0-2.fc42.tar.xz
time-created2024-11-13 02:09:09
time-finished2024-11-13 02:16:24
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-gcc-latest-x86_64' '-t' 'clippy,cppcheck,gcc,unicontrol,shellcheck' '-o' '/tmp/tmpe7ayunmt/netavark-1.13.0-2.fc42.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install=gcc-latest' '--gcc-analyzer-bin=/opt/gcc-latest/bin/gcc' '/tmp/tmpe7ayunmt/netavark-1.13.0-2.fc42.src.rpm'
tool-versioncsmock-3.7.1.20241107.094801.gb3f0f26.pr_192-1.el9