[IMPROVED] Mejorar funcionalidad de qr_secret.sh

- Utilizar dialog_input_filepath para selección de archivos
- Reordenar verificación de dialog para consistencia
- Codificar secreto en base64 para mayor seguridad
- Ajustar flujo lógico de la función principal

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Mauro Rosero P. 2025-03-19 07:21:30 -05:00
parent d32832b091
commit 7114c43475
Signed by: mrosero
GPG key ID: 83BD2A5F674B7E26
20 changed files with 68 additions and 50 deletions

11
.gitignore vendored
View file

@ -12,26 +12,21 @@
!bin/config/
!bin/ansible/
!inventory/
!templates/
!sops/
!proyectos/
!projects/
# Permitir el seguimiento de archivos específicos
# !archivo1.txt
!README.md
!CLUADE.md
!.gitignore
# Ignorar archivos específicos
CLAUDE.md
bin/config/rates/
# Permitir archivos en carpetas específicas
# !carpeta1/*.txt
!bin/*
!bin/lib/*
!bin/msg/*
!bin/config/*
!bin/config/**
!bin/ansible/**
!inventory/**
!templates/**
!sops/*.yaml

View file

@ -18,17 +18,21 @@
## Development Practices
- Use `bin/lib/base.lib` for common functions
- Use `bin/lib/developers.lib` for developers functions
- Use `bin/lib/clonsole.lib` for dialog functions
- Message files stored in `bin/msg/` (multilingual support)
- Configuration in `bin/config/` directory
- Use git commit messages with prefixes: [ADDED], [IMPROVED], [FIXED], [SOPS]
- Use git commit messages with prefixes: [ADDED], [IMPROVED], [FIXED], [SOPS], [INIT]
- Prefer podman over docker for container management
- All shell scripts (.sh) and Python scripts (.py) must be placed in the `bin/` directory unless explicitly specified otherwise
## Authorship Policy
- Use `bin/config/python.header` how example to python comment header
- Use `bin/config/bash.header` how example to bash comment header
- For new projects created by Claude Code, use author: "Cortana Rosero One <cortana@rosero.one>"
- Include reference indicating generation by Claude Code and the version used
- Example header comment:
```
# [Author] Cortana Rosero One <cortana@rosero.one>
# [Generated] Created by Claude Code (claude-3-7-sonnet-20250219)
```
```

10
bin/config/bash.head Normal file
View file

@ -0,0 +1,10 @@
#!/bin/bash
#
# Script: cversadm_token.sh
# Description: Administrador de tokens para plataformas de control de versiones
# Created: 2025/01/04 20:00:00
# Modified: 2025/03/15 16:08:03
# [Author] Cortana Rosero One <cortana@rosero.one>
# [Generated] Created by Claude Code (claude-3-7-sonnet-20250219)
#
# Derechos de Autor (C) [2025] [Mauro Rosero P. <mauro@rosero.one>]

View file

@ -1 +1 @@
proyectos
projects

View file

@ -0,0 +1 @@
57.73

View file

@ -0,0 +1 @@
23.64

View file

@ -0,0 +1 @@
51.00

View file

@ -0,0 +1 @@
56.81

View file

@ -0,0 +1 @@
59.11

View file

@ -0,0 +1 @@
49.00

View file

@ -0,0 +1 @@
41.00

View file

@ -0,0 +1 @@
88.66

View file

@ -0,0 +1 @@
49.00

1
bin/config/rates/ml.rate Normal file
View file

@ -0,0 +1 @@
49.00

View file

@ -0,0 +1 @@
47.00

View file

@ -0,0 +1 @@
20.00

View file

@ -0,0 +1 @@
49.00

View file

@ -0,0 +1 @@
49.00

View file

@ -0,0 +1 @@
31.00

View file

@ -53,12 +53,6 @@ apps_title="${qrmsg_000}"
# Verificar dependencias
check_dependencies() {
# Verificar si dialog está instalado
if ! command -v dialog &> /dev/null; then
# Sin dialog, tenemos que usar echo
echo "Error: ${qrmsg_013}. ${cvmsg_014}"
exit 1
fi
# Verificar si zbar está instalado
if ! command -v zbarimg &> /dev/null; then
@ -137,26 +131,6 @@ get_output_name() {
return 0
}
# Seleccionar archivo QR
select_qr_file() {
# Usar dialog directamente para seleccionar un archivo
local home_dir="$HOME/"
exec 3>&1
local selected_file=$(dialog --backtitle "$title" --title "${qrmsg_003}" \
--stdout --fselect "$home_dir" 15 60)
local exit_code=$?
exec 3>&-
if [ $exit_code -ne 0 ] || [ ! -f "$selected_file" ]; then
# Usuario canceló o no seleccionó un archivo válido
return 1
fi
echo "$selected_file"
return 0
}
# Extraer secreto de imagen QR
extract_secret() {
local qr_file="$1"
@ -180,7 +154,7 @@ extract_secret() {
fi
fi
echo "$secret"
echo "$(echo "$secret" | base64)"
return 0
}
@ -212,9 +186,40 @@ save_encrypted_secret() {
# Función principal
main() {
# Verificar si dialog está instalado
if ! command -v dialog &> /dev/null; then
# Sin dialog, tenemos que usar echo
echo "Error: ${qrmsg_013}. ${cvmsg_014}"
exit 1
fi
# Verificar dependencias
check_dependencies
# Seleccionar archivo QR
# Usar dialog_input_filepath de console.lib para seleccionar un archivo
local home_dir="$HOME/*.jpg"
dialog_input_filepath "$home_dir" "${qrmsg_003}"
if [ $? -ne 0 ]; then
clear
dialog_error_box "${head_info}" "${qrmsg_010}"
exit 0
fi
# Verificar el resultado
if [ "$valid_file" == "1" ]; then
qr_file="$result"
return 0
else
# Usuario canceló o no seleccionó un archivo válido
return 1
fi
# Extraer secreto de la imagen QR
local secret=$(extract_secret "$qr_file")
local extract_status=$?
# Solicitar nombre del archivo
local output_name=$(get_output_name)
if [ $? -ne 0 ]; then
@ -223,17 +228,6 @@ main() {
exit 0
fi
# Seleccionar archivo QR
local qr_file=$(select_qr_file)
if [ $? -ne 0 ]; then
clear
dialog_error_box "${head_info}" "${qrmsg_010}"
exit 0
fi
# Extraer secreto de la imagen QR
local secret=$(extract_secret "$qr_file")
local extract_status=$?
if [ $extract_status -ne 0 ]; then
dialog_error_box "${qrmsg_012}" "${qrmsg_007}"
@ -255,4 +249,4 @@ main() {
}
# Ejecutar función principal
main
main