Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci rustfmt v1 #9044

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ jobs:
fi
shell: bash {0}
- run: git clone https://github.com/OISF/libhtp -b 0.5.x
- run: ./qa/rustfmt.sh
catenacyber marked this conversation as resolved.
Show resolved Hide resolved
- run: ./autogen.sh
- run: ./configure --enable-unittests
- name: Check formatting
Expand Down
10 changes: 10 additions & 0 deletions qa/rustfmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
r=0
catenacyber marked this conversation as resolved.
Show resolved Hide resolved
cat qa/rustfmt.txt | while read i; do
rustfmt $i;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just call cargo fmt then check each file.

if [ $(git diff -- $i | wc -l) -gt 0 ]; then
git diff;
echo "$i" needs to be formatted
r=1;
fi
done
exit $r
57 changes: 57 additions & 0 deletions qa/rustfmt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
rust/derive/src/applayerframetype.rs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe build this list within the context of the rust/ directory, as in where its valid to run cargo fmt.

rust/src/detect/error.rs
rust/src/detect/iprep.rs
rust/src/detect/uint.rs
rust/src/detect/uri.rs
rust/src/detect/parser.rs
rust/src/detect/stream_size.rs
rust/src/ftp/event.rs
rust/src/ftp/mod.rs
rust/src/bittorrent_dht/logger.rs
rust/src/bittorrent_dht/parser.rs
rust/src/dcerpc/detect.rs
rust/src/util.rs
rust/src/applayertemplate/logger.rs
rust/src/applayertemplate/parser.rs
rust/src/jsonbuilder.rs
rust/src/lzma.rs
rust/src/rdp/util.rs
rust/src/rdp/error.rs
rust/src/rdp/windows.rs
rust/src/rfb/rfb.rs
rust/src/http2/huffman.rs
rust/src/x509/log.rs
rust/src/x509/time.rs
rust/src/ike/logger.rs
rust/src/ike/detect.rs
rust/src/ffi/strings.rs
rust/src/dhcp/detect.rs
rust/src/dhcp/parser.rs
rust/src/pgsql/logger.rs
rust/src/smb/ntlmssp_records.rs
rust/src/smb/events.rs
rust/src/smb/error.rs
rust/src/smb/smb2_records.rs
rust/src/sip/parser.rs
rust/src/mqtt/logger.rs
rust/src/mqtt/mqtt_message.rs
rust/src/mqtt/mqtt_property.rs
rust/src/plugin.rs
rust/src/dns/lua.rs
rust/src/dns/parser.rs
rust/src/modbus/log.rs
rust/src/modbus/detect.rs
rust/src/quic/logger.rs
rust/src/quic/error.rs
rust/src/quic/detect.rs
rust/src/quic/parser.rs
rust/src/quic/cyu.rs
rust/src/quic/crypto.rs
rust/src/common.rs
rust/src/sip/log.rs
rust/src/rdp/log.rs
rust/src/rfb/parser.rs
rust/src/http2/detect.rs
rust/src/ffi/base64.rs
rust/src/krb/detect.rs
rust/src/quic/frames.rs
2 changes: 1 addition & 1 deletion rust/src/ffi/base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* 02110-1301, USA.
*/

use std::os::raw::c_uchar;
use libc::c_ulong;
use std::os::raw::c_uchar;

#[repr(C)]
#[allow(non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion rust/src/http2/detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ fn http2_tx_get_resp_line(tx: &mut HTTP2Transaction) {
return;
}
let empty = Vec::new();
let mut resp_line : Vec<u8> = Vec::new();
let mut resp_line: Vec<u8> = Vec::new();

let status =
if let Ok(value) = http2_frames_get_header_firstvalue(tx, Direction::ToClient, ":status") {
Expand Down
1 change: 0 additions & 1 deletion rust/src/krb/detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ impl DetectKrb5TicketEncryptionList {
}
}


// Suppress large enum variant lint as the LIST is very large compared
// to the boolean variant.
#[derive(Debug)]
Expand Down
3 changes: 1 addition & 2 deletions rust/src/quic/frames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,7 @@ impl Frame {
let mut d = vec![0; crypto_max_size as usize];
for f in &frames {
if let Frame::CryptoFrag(c) = f {
d[c.offset as usize..(c.offset + c.length) as usize]
.clone_from_slice(&c.data);
d[c.offset as usize..(c.offset + c.length) as usize].clone_from_slice(&c.data);
}
}
if let Ok((_, msg)) = parse_tls_message_handshake(&d) {
Expand Down
2 changes: 1 addition & 1 deletion rust/src/rdp/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use super::rdp::{RdpTransaction, RdpTransactionItem};
use crate::jsonbuilder::{JsonBuilder, JsonError};
use crate::rdp::parser::*;
use crate::rdp::windows;
use x509_parser::prelude::{X509Certificate, FromDer};
use x509_parser::prelude::{FromDer, X509Certificate};

#[no_mangle]
pub extern "C" fn rs_rdp_to_json(tx: &mut RdpTransaction, js: &mut JsonBuilder) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion rust/src/rfb/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use nom7::*;
use std::fmt;
use std::str;

#[derive(Debug,PartialEq)]
#[derive(Debug, PartialEq)]
pub enum RFBGlobalState {
TCServerProtocolVersion,
TCSupportedSecurityTypes,
Expand Down
2 changes: 1 addition & 1 deletion rust/src/sip/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ fn log(tx: &SIPTransaction, js: &mut JsonBuilder) -> Result<(), JsonError> {
#[no_mangle]
pub extern "C" fn rs_sip_log_json(tx: &mut SIPTransaction, js: &mut JsonBuilder) -> bool {
log(tx, js).is_ok()
}
}