@codice-progressio/easy-permissions
Advanced tools
Sorry, the diff of this file is not supported yet
+19
-6
| const fs = require("fs") | ||
| const guard = require("express-jwt-permissions")() | ||
| let rutaCompletaFichero = "" | ||
| /** | ||
| * Un objeto con clave fichero1, fichero2 | ||
| */ | ||
| let rutaCompletaFichero = {} | ||
| const configuraciones = { | ||
@@ -11,3 +15,3 @@ // El path del fichero en el cual se van a estar agregando | ||
| nombreArchivoPermisos: "permisos.seguridad.js", | ||
| // El nombre de la carpeta | ||
| // El nombre de la carpeta | ||
| nombreCarpetaPermisos: "seguridad", | ||
@@ -23,3 +27,3 @@ // Generalmente recibe process.env.NODE_ENV | ||
| // en false impide que se registre cada tecla nueva dentro del permiso como | ||
| // una nueva linea en caso de usar auto-guardado. | ||
| // una nueva linea en caso de usar auto-guardado. | ||
| generarPermisos: false, | ||
@@ -46,3 +50,5 @@ } | ||
| const file = conf.nombreArchivoPermisos | ||
| const file2 = "_" + conf.nombreCarpetaPermisos | ||
| const dirFichero = dir.concat("/" + file) | ||
| const dirFichero2 = dir.concat("/" + file2) | ||
@@ -54,3 +60,5 @@ if (!fs.existsSync(dir)) fs.mkdirSync(dir) | ||
| if (!fs.existsSync(dirFichero)) fs.appendFileSync(dirFichero, datos) | ||
| return dirFichero | ||
| if (!fs.existsSync(dirFichero2)) fs.appendFileSync(dirFichero2, datos) | ||
| return { fichero1: dirFichero, fichero2: dirFichero2 } | ||
| } | ||
@@ -109,3 +117,4 @@ | ||
| // Leemos este mesmo archivo. | ||
| var data = fs.readFileSync(rutaCompletaFichero, "utf-8") | ||
| const data = fs.readFileSync(rutaCompletaFichero.fichero1, "utf-8") | ||
| const data2 = fs.readFileSync(rutaCompletaFichero.fichero2, "utf-8") | ||
@@ -124,4 +133,6 @@ // En modo produccion, o en caso de que el permiso exista, regresa el permiso | ||
| let texto = data.toString().split("\n") | ||
| let texto2 = data.toString().split("\n") | ||
| // Estructuramos | ||
| let nuevaLinea = ` "${permiso}":"${descripcion}",` | ||
| let nuevaLinea2 = ` "${permiso}":"${permiso}",` | ||
@@ -131,5 +142,7 @@ // Separamos el archivo en lineas. | ||
| texto.splice(1, 0, nuevaLinea) | ||
| texto2.splice(1, 0, nuevaLinea2) | ||
| // Escribimos el archivo | ||
| fs.writeFileSync(rutaCompletaFichero, texto.join("\n")) | ||
| fs.writeFileSync(rutaCompletaFichero.fichero1, texto.join("\n")) | ||
| fs.writeFileSync(rutaCompletaFichero.fichero2, texto2.join("\n")) | ||
| } catch (error) { | ||
@@ -136,0 +149,0 @@ throw new Error(msj("[ easyPermissions ] ", error)) |
+1
-1
| { | ||
| "name": "@codice-progressio/easy-permissions", | ||
| "version": "0.1.0", | ||
| "version": "0.2.0", | ||
| "description": "Permisos fáciles de crear y administrar.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
11287
5.67%6
20%162
7.28%