mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Encrypt archives at rest
This commit is contained in:
parent
7562a886e1
commit
a017aa7bfe
3 changed files with 47 additions and 1 deletions
20
backend/src/migrations/1600285077890-EncryptArchives.ts
Normal file
20
backend/src/migrations/1600285077890-EncryptArchives.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
import { decrypt, encrypt } from "../utils/crypt";
|
||||
|
||||
export class EncryptArchives1600285077890 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<any> {
|
||||
const archives = await queryRunner.query("SELECT id, body FROM archives");
|
||||
for (const archive of archives) {
|
||||
const encryptedBody = encrypt(archive.body);
|
||||
await queryRunner.query("UPDATE archives SET body = ? WHERE id = ?", [encryptedBody, archive.id]);
|
||||
}
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<any> {
|
||||
const archives = await queryRunner.query("SELECT id, body FROM archives");
|
||||
for (const archive of archives) {
|
||||
const decryptedBody = decrypt(archive.body);
|
||||
await queryRunner.query("UPDATE archives SET body = ? WHERE id = ?", [decryptedBody, archive.id]);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue