11use crate :: commands:: crypt_util:: { decrypt_env_item, decrypt_value} ;
2+ use crate :: commands:: model:: EnvFile ;
23use crate :: commands:: {
34 adjust_env_key, escape_shell_value, get_env_file_arg, get_private_key_for_file,
45 is_remote_env_file, read_content_from_dotenv_url, read_dotenv_url, std_output,
@@ -18,6 +19,10 @@ pub fn decrypt_command(command_matches: &ArgMatches, profile: &Option<String>) {
1819 return ;
1920 }
2021 let env_file = get_env_file_arg ( command_matches, profile) ;
22+ if command_matches. get_flag ( "verify" ) {
23+ verify_signature ( & env_file) ;
24+ return ;
25+ }
2126 let is_remote_env = is_remote_env_file ( & env_file) ;
2227 let env_file_path = std:: path:: PathBuf :: from ( & env_file) ;
2328 if !is_remote_env && !std:: path:: PathBuf :: from ( & env_file) . exists ( ) {
@@ -135,6 +140,34 @@ pub fn decrypt_env_entries(
135140 Ok ( entries)
136141}
137142
143+ fn verify_signature ( env_file_path : & str ) {
144+ if let Ok ( env_file) = EnvFile :: from ( env_file_path) {
145+ if env_file. is_signed ( ) {
146+ if env_file. is_verified ( ) {
147+ println ! (
148+ "{}" ,
149+ format!(
150+ "✔ The env file is signed, and the signature is valid ({env_file_path})" ,
151+ )
152+ . green( )
153+ ) ;
154+ } else {
155+ eprintln ! (
156+ "{}" ,
157+ format!(
158+ "✘ The env file is signed, but the signature is invalid ({env_file_path})"
159+ )
160+ . red( )
161+ ) ;
162+ }
163+ } else {
164+ eprintln ! ( "The env file is not signed" ) ;
165+ }
166+ } else {
167+ eprintln ! ( "Failed to parse the env file: {env_file_path}" ) ;
168+ }
169+ }
170+
138171#[ cfg( test) ]
139172mod tests {
140173 #[ test]
0 commit comments