diff --git a/modules/anonymizers/mysql/.testdata/mysql_test.dos.in.sql b/modules/anonymizers/mysql/.testdata/mysql_test.dos.in.sql new file mode 100644 index 0000000..f469582 --- /dev/null +++ b/modules/anonymizers/mysql/.testdata/mysql_test.dos.in.sql @@ -0,0 +1,106 @@ +-- MariaDB dump 10.19 Distrib 10.6.12-MariaDB, for debian-linux-gnu (x86_64) +-- +-- Host: 127.0.0.1 Database: db +-- ------------------------------------------------------ +-- Server version 8.0.32 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `table1` +-- + +DROP TABLE IF EXISTS `table1`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `table1` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `url` varchar(255) NOT NULL, + `auth_method` varchar(20) NOT NULL DEFAULT 'none', + `auth_data` text NOT NULL, + `username` varchar(20) NOT NULL DEFAULT '', + `password` varchar(20) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `table1` +-- + +LOCK TABLES `table1` WRITE; +/*!40000 ALTER TABLE `table1` DISABLE KEYS */; +INSERT INTO `table1` VALUES (1,'test4','https://github.com/nixys/nxs-rbac-operator0.git','none','','',''),(2,'test5','https://github.com/nixys/nxs-rbac-operator.git','none','','',''),(3,'test6','https://github.com/nixys/nxs-rbac-operator2.git','none','','',''); +/*!40000 ALTER TABLE `table1` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `table2` +-- + +DROP TABLE IF EXISTS `table2`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `table2` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `url` varchar(255) NOT NULL, + `auth_method` varchar(20) NOT NULL DEFAULT 'none', + `auth_data` text NOT NULL, + `username` varchar(20) NOT NULL DEFAULT '', + `password` varchar(20) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `table2` +-- + +LOCK TABLES `table2` WRITE; +/*!40000 ALTER TABLE `table2` DISABLE KEYS */; +INSERT INTO `table2` VALUES (1,'test4','https://github.com/nixys/nxs-rbac-operator0.git','none','','',''),(2,'test5','https://github.com/nixys/nxs-rbac-operator.git','none','','',''),(3,'test6','https://github.com/nixys/nxs-rbac-operator2.git','none','','',''); +/*!40000 ALTER TABLE `table2` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `table3` +-- + +DROP TABLE IF EXISTS `table3`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `table3` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `url` varchar(255) NOT NULL, + `auth_method` varchar(20) NOT NULL DEFAULT 'none', + `auth_data` text NOT NULL, + `username` varchar(20) NOT NULL DEFAULT '', + `password` varchar(20) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `table3` +-- + +LOCK TABLES `table3` WRITE; +/*!40000 ALTER TABLE `table3` DISABLE KEYS */; +INSERT INTO `table3` VALUES (1,'test4','https://github.com/nixys/nxs-rbac-operator0.git','none','','',''),(2,'test5','https://github.com/nixys/nxs-rbac-operator.git','none','','',''),(3,'test6','https://github.com/nixys/nxs-rbac-operator2.git','none','','',''); +/*!40000 ALTER TABLE `table3` ENABLE KEYS */; +UNLOCK TABLES; \ No newline at end of file diff --git a/modules/anonymizers/mysql/.testdata/mysql_test.dos.out.sql b/modules/anonymizers/mysql/.testdata/mysql_test.dos.out.sql new file mode 100644 index 0000000..1d091a7 --- /dev/null +++ b/modules/anonymizers/mysql/.testdata/mysql_test.dos.out.sql @@ -0,0 +1,106 @@ +-- MariaDB dump 10.19 Distrib 10.6.12-MariaDB, for debian-linux-gnu (x86_64) +-- +-- Host: 127.0.0.1 Database: db +-- ------------------------------------------------------ +-- Server version 8.0.32 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `table1` +-- + +DROP TABLE IF EXISTS `table1`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `table1` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `url` varchar(255) NOT NULL, + `auth_method` varchar(20) NOT NULL DEFAULT 'none', + `auth_data` text NOT NULL, + `username` varchar(20) NOT NULL DEFAULT '', + `password` varchar(20) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `table1` +-- + +LOCK TABLES `table1` WRITE; +/*!40000 ALTER TABLE `table1` DISABLE KEYS */; +INSERT INTO `table1` VALUES (1,'test4','https://github.com/nixys/nxs-rbac-operator0.git','none','','',''),(3,'test6','https://github.com/nixys/nxs-rbac-operator2.git','none','','',''); +/*!40000 ALTER TABLE `table1` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `table2` +-- + +DROP TABLE IF EXISTS `table2`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `table2` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `url` varchar(255) NOT NULL, + `auth_method` varchar(20) NOT NULL DEFAULT 'none', + `auth_data` text NOT NULL, + `username` varchar(20) NOT NULL DEFAULT '', + `password` varchar(20) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `table2` +-- + +LOCK TABLES `table2` WRITE; +/*!40000 ALTER TABLE `table2` DISABLE KEYS */; + +/*!40000 ALTER TABLE `table2` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `table3` +-- + +DROP TABLE IF EXISTS `table3`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `table3` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `url` varchar(255) NOT NULL, + `auth_method` varchar(20) NOT NULL DEFAULT 'none', + `auth_data` text NOT NULL, + `username` varchar(20) NOT NULL DEFAULT '', + `password` varchar(20) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb3; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `table3` +-- + +LOCK TABLES `table3` WRITE; +/*!40000 ALTER TABLE `table3` DISABLE KEYS */; +INSERT INTO `table3` VALUES (1,'test4','https://github.com/nixys/nxs-rbac-operator0.git','none','','',''),(2,'test5','https://github.com/nixys/nxs-rbac-operator.git','none','','',''),(3,'test6','https://github.com/nixys/nxs-rbac-operator2.git','none','','',''); +/*!40000 ALTER TABLE `table3` ENABLE KEYS */; +UNLOCK TABLES; \ No newline at end of file diff --git a/modules/anonymizers/mysql/mysql_test.in.sql b/modules/anonymizers/mysql/.testdata/mysql_test.in.sql similarity index 100% rename from modules/anonymizers/mysql/mysql_test.in.sql rename to modules/anonymizers/mysql/.testdata/mysql_test.in.sql diff --git a/modules/anonymizers/mysql/mysql_test.out.sql b/modules/anonymizers/mysql/.testdata/mysql_test.out.sql similarity index 100% rename from modules/anonymizers/mysql/mysql_test.out.sql rename to modules/anonymizers/mysql/.testdata/mysql_test.out.sql diff --git a/modules/anonymizers/mysql/mysql.go b/modules/anonymizers/mysql/mysql.go index 93678f3..f0a5844 100644 --- a/modules/anonymizers/mysql/mysql.go +++ b/modules/anonymizers/mysql/mysql.go @@ -324,7 +324,7 @@ func (m *MySQL) Run(ctx context.Context, w io.Writer) error { Switch: fsm.Switch{ Trigger: []byte(","), Delimiters: fsm.Delimiters{ - R: []byte{'\n'}, + R: []byte{'\n', '\r'}, }, }, DataHandler: nil, @@ -359,7 +359,7 @@ func (m *MySQL) Run(ctx context.Context, w io.Writer) error { Switch: fsm.Switch{ Trigger: []byte(","), Delimiters: fsm.Delimiters{ - R: []byte{'\n'}, + R: []byte{'\n', '\r'}, }, }, DataHandler: dhCreateTableColumnAdd, @@ -383,7 +383,7 @@ func (m *MySQL) Run(ctx context.Context, w io.Writer) error { Switch: fsm.Switch{ Trigger: []byte(";"), Delimiters: fsm.Delimiters{ - R: []byte{'\n'}, + R: []byte{'\n', '\r'}, }, }, DataHandler: nil, @@ -447,7 +447,7 @@ func (m *MySQL) Run(ctx context.Context, w io.Writer) error { Trigger: []byte("VALUES"), Delimiters: fsm.Delimiters{ L: []byte{' ', '\n'}, - R: []byte{' ', '\n'}, + R: []byte{' ', '\n', '\r'}, }, }, DataHandler: dhSecurityInsertIntoValues, diff --git a/modules/anonymizers/mysql/mysql_test.go b/modules/anonymizers/mysql/mysql_test.go index 90cfd30..8243097 100644 --- a/modules/anonymizers/mysql/mysql_test.go +++ b/modules/anonymizers/mysql/mysql_test.go @@ -14,7 +14,7 @@ func TestMySQL(t *testing.T) { var r, e bytes.Buffer - fin, err := os.Open("mysql_test.in.sql") + fin, err := os.Open(".testdata/mysql_test.in.sql") if err != nil { t.Fatal("open input SQL:", err) } @@ -63,7 +63,7 @@ func TestMySQL(t *testing.T) { t.Fatal("run MySQL:", err) } - fout, err := os.Open("mysql_test.out.sql") + fout, err := os.Open(".testdata/mysql_test.out.sql") if err != nil { t.Fatal("open output SQL:", err) } @@ -72,7 +72,78 @@ func TestMySQL(t *testing.T) { t.Fatal("read output SQL:", err) } - // os.WriteFile("mysql_test.out.sql", r.Bytes(), 0644) + // os.WriteFile(".testdata/mysql_test.out.sql", r.Bytes(), 0644) + + if r.String() != e.String() { + t.Fatal("incorrect anonymization result") + } + + t.Logf("success") +} + +func TestMySQLDos(t *testing.T) { + + var r, e bytes.Buffer + + fin, err := os.Open(".testdata/mysql_test.dos.in.sql") + if err != nil { + t.Fatal("open input SQL:", err) + } + + m, err := Init( + fin, + InitOpts{ + Rules: RulesOpts{ + TableRules: map[string]map[string]relfilter.ColumnRuleOpts{ + + // Delete only row with id `2` + "table1": { + "id": relfilter.ColumnRuleOpts{ + Type: misc.ValueTypeTemplate, + Value: "{{ if eq .Values.id \"2\" }}{{ drop }}{{ else }}{{ .Values.id }}{{ end }}", + Unique: false, + }, + }, + + // Delete all rows from table + "table2": { + "id": relfilter.ColumnRuleOpts{ + Type: misc.ValueTypeTemplate, + Value: "{{ drop }}", + Unique: false, + }, + }, + + // Delete no rows + "table3": { + "id": relfilter.ColumnRuleOpts{ + Type: misc.ValueTypeTemplate, + Value: "{{ if eq .Values.id \"4\" }}{{ drop }}{{ else }}{{ .Values.id }}{{ end }}", + Unique: false, + }, + }, + }, + }, + }, + ) + if err != nil { + t.Fatal("init MySQL:", err) + } + + if err := m.Run(context.Background(), &r); err != nil { + t.Fatal("run MySQL:", err) + } + + fout, err := os.Open(".testdata/mysql_test.dos.out.sql") + if err != nil { + t.Fatal("open output SQL:", err) + } + + if _, err := e.ReadFrom(fout); err != nil { + t.Fatal("read output SQL:", err) + } + + // os.WriteFile(".testdata/mysql_test.dos.out.sql", r.Bytes(), 0644) if r.String() != e.String() { t.Fatal("incorrect anonymization result") diff --git a/modules/anonymizers/pgsql/.testdata/pgsql_test.dos.in.sql b/modules/anonymizers/pgsql/.testdata/pgsql_test.dos.in.sql new file mode 100644 index 0000000..037e8a3 --- /dev/null +++ b/modules/anonymizers/pgsql/.testdata/pgsql_test.dos.in.sql @@ -0,0 +1,176 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 16.3 (Debian 16.3-1.pgdg120+1) +-- Dumped by pg_dump version 16.3 (Debian 16.3-1.pgdg120+1) + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- Name: list_types; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.list_types ( + integer_type integer, + numeric_type numeric, + double_precision_type double precision, + varchar_type character varying, + text_type text, + date_type date, + time_tz_type time with time zone, + boolean_type boolean, + xml_type xml, + jsonb_type jsonb, + id bigint NOT NULL +); + + +ALTER TABLE public.list_types OWNER TO postgres; + +-- +-- Name: list_types2; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.list_types2 ( + integer_type integer, + numeric_type numeric, + double_precision_type double precision, + varchar_type character varying, + text_type text, + date_type date, + time_tz_type time with time zone, + boolean_type boolean, + xml_type xml, + jsonb_type jsonb, + id bigint NOT NULL +); + + +ALTER TABLE public.list_types2 OWNER TO postgres; + +-- +-- Name: list_types3; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.list_types3 ( + integer_type integer, + numeric_type numeric, + double_precision_type double precision, + varchar_type character varying, + text_type text, + date_type date, + time_tz_type time with time zone, + boolean_type boolean, + xml_type xml, + jsonb_type jsonb, + id bigint NOT NULL +); + + +ALTER TABLE public.list_types3 OWNER TO postgres; + +-- +-- Name: list_types_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.list_types_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.list_types_id_seq OWNER TO postgres; + +-- +-- Name: list_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.list_types_id_seq OWNED BY public.list_types.id; + + +-- +-- Name: list_types id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.list_types ALTER COLUMN id SET DEFAULT nextval('public.list_types_id_seq'::regclass); + + +-- +-- Data for Name: list_types; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.list_types (integer_type, numeric_type, double_precision_type, varchar_type, text_type, date_type, time_tz_type, boolean_type, xml_type, jsonb_type, id) FROM stdin; +\N 42.99465 \N Biba \N \N 19:51:50+00 \N \N \N 6 +\N -84.46685 \N Pupa \N \N 03:34:36+00 \N \N \N 2 +\N 72.52040 \N Lupa \N 15:17:37+00 t \N \N 4 +\N 99.37111 \N Boba \N 03:34:36+00 \N \N \N 8 +\N -90.90125 \N Cerebla \N \N 22:00:45+00 \N \N \N 10 +8765542 \N 7.84023409 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vel pretium lectus quam id leo in vitae. Dignissim cras tincidunt lobortis feugiat vivamus at augue. Sit amet aliquam id diam maecenas. Ornare lectus sit amet est placerat in egestas erat. Et malesuada fames ac turpis egestas maecenas pharetra convallis. Orci sagittis eu volutpat odio facilisis. Mauris in aliquam sem fringilla ut morbi tincidunt augue interdum. Nisi porta lorem mollis aliquam ut porttitor leo a diam. Amet purus gravida quis blandit turpis cursus in. Risus feugiat in ante metus. Purus viverra accumsan in nisl nisi scelerisque eu ultrices vitae. Faucibus nisl tincidunt eget nullam. Lectus quam id leo in vitae turpis massa. Nisl nunc mi ipsum faucibus vitae aliquet nec ullamcorper sit. Pretium lectus quam id leo in vitae turpis massa. Blandit aliquam etiam erat velit scelerisque in dictum non. Eu nisl nunc mi ipsum faucibus vitae. 1996-06-15 \N t \n 721744494.7994413\n -26197703.515699387\n event\n \n among\n couple\n official\n spring\n 1032613367\n \n 198858711\n {"truck": 1563128845, "little": -1009907448.0705619, "possible": "gave"} 1 +4562892 \N 5.8024375 \N Massa sapien faucibus et molestie ac. Praesent elementum facilisis leo vel. Turpis egestas pretium aenean pharetra magna. Facilisi cras fermentum odio eu feugiat pretium nibh ipsum consequat. Auctor neque vitae tempus quam pellentesque. Ornare aenean euismod elementum nisi quis eleifend. Purus sit amet luctus venenatis lectus. Tortor consequat id porta nibh venenatis cras sed felis eget. Felis bibendum ut tristique et egestas quis ipsum. Pretium fusce id velit ut tortor pretium viverra. Nam aliquam sem et tortor consequat. Nisl pretium fusce id velit. Sem integer vitae justo eget magna fermentum iaculis. Sit amet nulla facilisi morbi tempus iaculis urna id volutpat. Vitae auctor eu augue ut lectus arcu. Malesuada fames ac turpis egestas. Ac odio tempor orci dapibus ultrices in. Amet massa vitae tortor condimentum lacinia quis vel eros donec. Et malesuada fames ac turpis egestas integer. Sodales ut eu sem integer vitae justo eget. 2031-07-14 \N f \n \n -598731677.6283197\n variety\n 46234734.5525651\n rising\n -1556052082.582368\n \n eleven\n 1863692621\n -139561185.33627748\n funny\n [{"ago": {"shut": "seven", "found": 469996577.0459976, "climate": "early"}, "scene": "slightly", "medicine": true}, true, true] 3 +87689278 \N -0.31813426 Id donec ultrices tincidunt arcu. Id nibh tortor id aliquet lectus. Condimentum mattis pellentesque id nibh tortor id aliquet lectus proin. Cursus vitae congue mauris rhoncus. Eu ultrices vitae auctor eu augue ut lectus arcu bibendum. Sed turpis tincidunt id aliquet. Feugiat scelerisque varius morbi enim nunc faucibus a pellentesque sit. Diam donec adipiscing tristique risus nec feugiat in fermentum posuere. Scelerisque eu ultrices vitae auctor eu augue ut. Volutpat ac tincidunt vitae semper quis. 1976-12-10 \N t \n rise\n \n consist\n someone\n white\n victory\n -761134241.8632131\n \n 1111641157\n 744054503\n 1876042205.1417785\n {"torn": [false, -1325125579, false], "rising": false, "volume": "grow"} 9 +687527896 \N -1.81914025 Facilisi etiam dignissim diam quis enim. Diam ut venenatis tellus in metus vulputate eu. Mattis rhoncus urna neque viverra justo nec ultrices. Sagittis nisl rhoncus mattis rhoncus urna neque viverra. Nec ullamcorper sit amet risus nullam eget felis eget. Fames ac turpis egestas maecenas pharetra convallis posuere. Eget arcu dictum varius duis at consectetur lorem. Porta lorem mollis aliquam ut porttitor leo a diam sollicitudin. Magna fermentum iaculis eu non diam phasellus vestibulum lorem sed. Etiam non quam lacus suspendisse. Parturient montes nascetur ridiculus mus. Ornare suspendisse sed nisi lacus sed viverra tellus in. Interdum velit euismod in pellentesque massa placerat duis ultricies lacus. Urna nec tincidunt praesent semper feugiat nibh sed pulvinar. 2051-05-16 \N t \n \n 398209907.5902777\n wind\n parallel\n paint\n -1386172501\n \n previous\n skill\n conversation\n keep\n [[-128477882.56726694, 1569798072.8967233, {"us": 438307927.6373253, "think": -870063635, "product": "stuck"}], [{"name": "broad", "took": "brother", "alphabet": -731303259}, [-1065068182.0998564, "finish", "up"], false], false] 5 +8767542 \N 5.08081291 \N Fames ac turpis egestas maecenas. Volutpat lacus laoreet non curabitur gravida arcu ac tortor. Sit amet commodo nulla facilisi nullam vehicula. Ipsum dolor sit amet consectetur adipiscing elit pellentesque. Maecenas ultricies mi eget mauris pharetra. Sed faucibus turpis in eu mi bibendum. Massa ultricies mi quis hendrerit dolor magna. Non diam phasellus vestibulum lorem sed. Vestibulum mattis ullamcorper velit sed ullamcorper morbi tincidunt ornare massa. Massa ultricies mi quis hendrerit dolor magna eget est lorem. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus. 2058-03-29 \N f \n concerned\n -1671936329.7007055\n slept\n how\n -1838021068\n {"basis": "mine", "company": {"tired": false, "prevent": false, "suppose": 735075799}, "worried": {"iron": 378563223.91183805, "nest": false, "raise": {"date": false, "engineer": true, "television": 136840736.65782642}}} 7 +\. + + +-- +-- Data for Name: list_types2; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.list_types2 (integer_type, numeric_type, double_precision_type, varchar_type, text_type, date_type, time_tz_type, boolean_type, xml_type, jsonb_type, id) FROM stdin; +8765542 \N 7.84023409 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vel pretium lectus quam id leo in vitae. Dignissim cras tincidunt lobortis feugiat vivamus at augue. Sit amet aliquam id diam maecenas. Ornare lectus sit amet est placerat in egestas erat. Et malesuada fames ac turpis egestas maecenas pharetra convallis. Orci sagittis eu volutpat odio facilisis. Mauris in aliquam sem fringilla ut morbi tincidunt augue interdum. Nisi porta lorem mollis aliquam ut porttitor leo a diam. Amet purus gravida quis blandit turpis cursus in. Risus feugiat in ante metus. Purus viverra accumsan in nisl nisi scelerisque eu ultrices vitae. Faucibus nisl tincidunt eget nullam. Lectus quam id leo in vitae turpis massa. Nisl nunc mi ipsum faucibus vitae aliquet nec ullamcorper sit. Pretium lectus quam id leo in vitae turpis massa. Blandit aliquam etiam erat velit scelerisque in dictum non. Eu nisl nunc mi ipsum faucibus vitae. 1996-06-15 \N t \n 721744494.7994413\n -26197703.515699387\n event\n \n among\n couple\n official\n spring\n 1032613367\n \n 198858711\n {"truck": 1563128845, "little": -1009907448.0705619, "possible": "gave"} 1 +4562892 \N 5.8024375 \N Massa sapien faucibus et molestie ac. Praesent elementum facilisis leo vel. Turpis egestas pretium aenean pharetra magna. Facilisi cras fermentum odio eu feugiat pretium nibh ipsum consequat. Auctor neque vitae tempus quam pellentesque. Ornare aenean euismod elementum nisi quis eleifend. Purus sit amet luctus venenatis lectus. Tortor consequat id porta nibh venenatis cras sed felis eget. Felis bibendum ut tristique et egestas quis ipsum. Pretium fusce id velit ut tortor pretium viverra. Nam aliquam sem et tortor consequat. Nisl pretium fusce id velit. Sem integer vitae justo eget magna fermentum iaculis. Sit amet nulla facilisi morbi tempus iaculis urna id volutpat. Vitae auctor eu augue ut lectus arcu. Malesuada fames ac turpis egestas. Ac odio tempor orci dapibus ultrices in. Amet massa vitae tortor condimentum lacinia quis vel eros donec. Et malesuada fames ac turpis egestas integer. Sodales ut eu sem integer vitae justo eget. 2031-07-14 \N f \n \n -598731677.6283197\n variety\n 46234734.5525651\n rising\n -1556052082.582368\n \n eleven\n 1863692621\n -139561185.33627748\n funny\n [{"ago": {"shut": "seven", "found": 469996577.0459976, "climate": "early"}, "scene": "slightly", "medicine": true}, true, true] 3 +87689278 \N -0.31813426 Id donec ultrices tincidunt arcu. Id nibh tortor id aliquet lectus. Condimentum mattis pellentesque id nibh tortor id aliquet lectus proin. Cursus vitae congue mauris rhoncus. Eu ultrices vitae auctor eu augue ut lectus arcu bibendum. Sed turpis tincidunt id aliquet. Feugiat scelerisque varius morbi enim nunc faucibus a pellentesque sit. Diam donec adipiscing tristique risus nec feugiat in fermentum posuere. Scelerisque eu ultrices vitae auctor eu augue ut. Volutpat ac tincidunt vitae semper quis. 1976-12-10 \N t \n rise\n \n consist\n someone\n white\n victory\n -761134241.8632131\n \n 1111641157\n 744054503\n 1876042205.1417785\n {"torn": [false, -1325125579, false], "rising": false, "volume": "grow"} 9 +687527896 \N -1.81914025 Facilisi etiam dignissim diam quis enim. Diam ut venenatis tellus in metus vulputate eu. Mattis rhoncus urna neque viverra justo nec ultrices. Sagittis nisl rhoncus mattis rhoncus urna neque viverra. Nec ullamcorper sit amet risus nullam eget felis eget. Fames ac turpis egestas maecenas pharetra convallis posuere. Eget arcu dictum varius duis at consectetur lorem. Porta lorem mollis aliquam ut porttitor leo a diam sollicitudin. Magna fermentum iaculis eu non diam phasellus vestibulum lorem sed. Etiam non quam lacus suspendisse. Parturient montes nascetur ridiculus mus. Ornare suspendisse sed nisi lacus sed viverra tellus in. Interdum velit euismod in pellentesque massa placerat duis ultricies lacus. Urna nec tincidunt praesent semper feugiat nibh sed pulvinar. 2051-05-16 \N t \n \n 398209907.5902777\n wind\n parallel\n paint\n -1386172501\n \n previous\n skill\n conversation\n keep\n [[-128477882.56726694, 1569798072.8967233, {"us": 438307927.6373253, "think": -870063635, "product": "stuck"}], [{"name": "broad", "took": "brother", "alphabet": -731303259}, [-1065068182.0998564, "finish", "up"], false], false] 5 +8767542 \N 5.08081291 \N Fames ac turpis egestas maecenas. Volutpat lacus laoreet non curabitur gravida arcu ac tortor. Sit amet commodo nulla facilisi nullam vehicula. Ipsum dolor sit amet consectetur adipiscing elit pellentesque. Maecenas ultricies mi eget mauris pharetra. Sed faucibus turpis in eu mi bibendum. Massa ultricies mi quis hendrerit dolor magna. Non diam phasellus vestibulum lorem sed. Vestibulum mattis ullamcorper velit sed ullamcorper morbi tincidunt ornare massa. Massa ultricies mi quis hendrerit dolor magna eget est lorem. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus. 2058-03-29 \N f \n concerned\n -1671936329.7007055\n slept\n how\n -1838021068\n {"basis": "mine", "company": {"tired": false, "prevent": false, "suppose": 735075799}, "worried": {"iron": 378563223.91183805, "nest": false, "raise": {"date": false, "engineer": true, "television": 136840736.65782642}}} 7 +\. + + +-- +-- Data for Name: list_types3; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.list_types3 (integer_type, numeric_type, double_precision_type, varchar_type, text_type, date_type, time_tz_type, boolean_type, xml_type, jsonb_type, id) FROM stdin; +8765542 \N 7.84023409 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vel pretium lectus quam id leo in vitae. Dignissim cras tincidunt lobortis feugiat vivamus at augue. Sit amet aliquam id diam maecenas. Ornare lectus sit amet est placerat in egestas erat. Et malesuada fames ac turpis egestas maecenas pharetra convallis. Orci sagittis eu volutpat odio facilisis. Mauris in aliquam sem fringilla ut morbi tincidunt augue interdum. Nisi porta lorem mollis aliquam ut porttitor leo a diam. Amet purus gravida quis blandit turpis cursus in. Risus feugiat in ante metus. Purus viverra accumsan in nisl nisi scelerisque eu ultrices vitae. Faucibus nisl tincidunt eget nullam. Lectus quam id leo in vitae turpis massa. Nisl nunc mi ipsum faucibus vitae aliquet nec ullamcorper sit. Pretium lectus quam id leo in vitae turpis massa. Blandit aliquam etiam erat velit scelerisque in dictum non. Eu nisl nunc mi ipsum faucibus vitae. 1996-06-15 \N t \n 721744494.7994413\n -26197703.515699387\n event\n \n among\n couple\n official\n spring\n 1032613367\n \n 198858711\n {"truck": 1563128845, "little": -1009907448.0705619, "possible": "gave"} 1 +4562892 \N 5.8024375 \N Massa sapien faucibus et molestie ac. Praesent elementum facilisis leo vel. Turpis egestas pretium aenean pharetra magna. Facilisi cras fermentum odio eu feugiat pretium nibh ipsum consequat. Auctor neque vitae tempus quam pellentesque. Ornare aenean euismod elementum nisi quis eleifend. Purus sit amet luctus venenatis lectus. Tortor consequat id porta nibh venenatis cras sed felis eget. Felis bibendum ut tristique et egestas quis ipsum. Pretium fusce id velit ut tortor pretium viverra. Nam aliquam sem et tortor consequat. Nisl pretium fusce id velit. Sem integer vitae justo eget magna fermentum iaculis. Sit amet nulla facilisi morbi tempus iaculis urna id volutpat. Vitae auctor eu augue ut lectus arcu. Malesuada fames ac turpis egestas. Ac odio tempor orci dapibus ultrices in. Amet massa vitae tortor condimentum lacinia quis vel eros donec. Et malesuada fames ac turpis egestas integer. Sodales ut eu sem integer vitae justo eget. 2031-07-14 \N f \n \n -598731677.6283197\n variety\n 46234734.5525651\n rising\n -1556052082.582368\n \n eleven\n 1863692621\n -139561185.33627748\n funny\n [{"ago": {"shut": "seven", "found": 469996577.0459976, "climate": "early"}, "scene": "slightly", "medicine": true}, true, true] 3 +87689278 \N -0.31813426 Id donec ultrices tincidunt arcu. Id nibh tortor id aliquet lectus. Condimentum mattis pellentesque id nibh tortor id aliquet lectus proin. Cursus vitae congue mauris rhoncus. Eu ultrices vitae auctor eu augue ut lectus arcu bibendum. Sed turpis tincidunt id aliquet. Feugiat scelerisque varius morbi enim nunc faucibus a pellentesque sit. Diam donec adipiscing tristique risus nec feugiat in fermentum posuere. Scelerisque eu ultrices vitae auctor eu augue ut. Volutpat ac tincidunt vitae semper quis. 1976-12-10 \N t \n rise\n \n consist\n someone\n white\n victory\n -761134241.8632131\n \n 1111641157\n 744054503\n 1876042205.1417785\n {"torn": [false, -1325125579, false], "rising": false, "volume": "grow"} 9 +687527896 \N -1.81914025 Facilisi etiam dignissim diam quis enim. Diam ut venenatis tellus in metus vulputate eu. Mattis rhoncus urna neque viverra justo nec ultrices. Sagittis nisl rhoncus mattis rhoncus urna neque viverra. Nec ullamcorper sit amet risus nullam eget felis eget. Fames ac turpis egestas maecenas pharetra convallis posuere. Eget arcu dictum varius duis at consectetur lorem. Porta lorem mollis aliquam ut porttitor leo a diam sollicitudin. Magna fermentum iaculis eu non diam phasellus vestibulum lorem sed. Etiam non quam lacus suspendisse. Parturient montes nascetur ridiculus mus. Ornare suspendisse sed nisi lacus sed viverra tellus in. Interdum velit euismod in pellentesque massa placerat duis ultricies lacus. Urna nec tincidunt praesent semper feugiat nibh sed pulvinar. 2051-05-16 \N t \n \n 398209907.5902777\n wind\n parallel\n paint\n -1386172501\n \n previous\n skill\n conversation\n keep\n [[-128477882.56726694, 1569798072.8967233, {"us": 438307927.6373253, "think": -870063635, "product": "stuck"}], [{"name": "broad", "took": "brother", "alphabet": -731303259}, [-1065068182.0998564, "finish", "up"], false], false] 5 +8767542 \N 5.08081291 \N Fames ac turpis egestas maecenas. Volutpat lacus laoreet non curabitur gravida arcu ac tortor. Sit amet commodo nulla facilisi nullam vehicula. Ipsum dolor sit amet consectetur adipiscing elit pellentesque. Maecenas ultricies mi eget mauris pharetra. Sed faucibus turpis in eu mi bibendum. Massa ultricies mi quis hendrerit dolor magna. Non diam phasellus vestibulum lorem sed. Vestibulum mattis ullamcorper velit sed ullamcorper morbi tincidunt ornare massa. Massa ultricies mi quis hendrerit dolor magna eget est lorem. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus. 2058-03-29 \N f \n concerned\n -1671936329.7007055\n slept\n how\n -1838021068\n {"basis": "mine", "company": {"tired": false, "prevent": false, "suppose": 735075799}, "worried": {"iron": 378563223.91183805, "nest": false, "raise": {"date": false, "engineer": true, "television": 136840736.65782642}}} 7 +\. + + +-- +-- Name: list_types_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.list_types_id_seq', 10, true); + + +-- +-- Name: list_types list_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.list_types + ADD CONSTRAINT list_types_pkey PRIMARY KEY (id); + + +-- +-- PostgreSQL database dump complete +-- + diff --git a/modules/anonymizers/pgsql/.testdata/pgsql_test.dos.out.sql b/modules/anonymizers/pgsql/.testdata/pgsql_test.dos.out.sql new file mode 100644 index 0000000..bdb8c57 --- /dev/null +++ b/modules/anonymizers/pgsql/.testdata/pgsql_test.dos.out.sql @@ -0,0 +1,169 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 16.3 (Debian 16.3-1.pgdg120+1) +-- Dumped by pg_dump version 16.3 (Debian 16.3-1.pgdg120+1) + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- Name: list_types; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.list_types ( + integer_type integer, + numeric_type numeric, + double_precision_type double precision, + varchar_type character varying, + text_type text, + date_type date, + time_tz_type time with time zone, + boolean_type boolean, + xml_type xml, + jsonb_type jsonb, + id bigint NOT NULL +); + + +ALTER TABLE public.list_types OWNER TO postgres; + +-- +-- Name: list_types2; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.list_types2 ( + integer_type integer, + numeric_type numeric, + double_precision_type double precision, + varchar_type character varying, + text_type text, + date_type date, + time_tz_type time with time zone, + boolean_type boolean, + xml_type xml, + jsonb_type jsonb, + id bigint NOT NULL +); + + +ALTER TABLE public.list_types2 OWNER TO postgres; + +-- +-- Name: list_types3; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.list_types3 ( + integer_type integer, + numeric_type numeric, + double_precision_type double precision, + varchar_type character varying, + text_type text, + date_type date, + time_tz_type time with time zone, + boolean_type boolean, + xml_type xml, + jsonb_type jsonb, + id bigint NOT NULL +); + + +ALTER TABLE public.list_types3 OWNER TO postgres; + +-- +-- Name: list_types_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.list_types_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.list_types_id_seq OWNER TO postgres; + +-- +-- Name: list_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.list_types_id_seq OWNED BY public.list_types.id; + + +-- +-- Name: list_types id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.list_types ALTER COLUMN id SET DEFAULT nextval('public.list_types_id_seq'::regclass); + + +-- +-- Data for Name: list_types; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.list_types (integer_type, numeric_type, double_precision_type, varchar_type, text_type, date_type, time_tz_type, boolean_type, xml_type, jsonb_type, id) FROM stdin; +\N 42.99465 \N Biba \N \N 19:51:50+00 \N \N \N 6 +\N -84.46685 \N Pupa \N \N 03:34:36+00 \N \N \N 2 +\N 72.52040 \N Lupa \N 15:17:37+00 t \N \N 4 +\N 99.37111 \N Boba \N 03:34:36+00 \N \N \N 8 +\N -90.90125 \N Cerebla \N \N 22:00:45+00 \N \N \N 10 +4562892 \N 5.8024375 \N Massa sapien faucibus et molestie ac. Praesent elementum facilisis leo vel. Turpis egestas pretium aenean pharetra magna. Facilisi cras fermentum odio eu feugiat pretium nibh ipsum consequat. Auctor neque vitae tempus quam pellentesque. Ornare aenean euismod elementum nisi quis eleifend. Purus sit amet luctus venenatis lectus. Tortor consequat id porta nibh venenatis cras sed felis eget. Felis bibendum ut tristique et egestas quis ipsum. Pretium fusce id velit ut tortor pretium viverra. Nam aliquam sem et tortor consequat. Nisl pretium fusce id velit. Sem integer vitae justo eget magna fermentum iaculis. Sit amet nulla facilisi morbi tempus iaculis urna id volutpat. Vitae auctor eu augue ut lectus arcu. Malesuada fames ac turpis egestas. Ac odio tempor orci dapibus ultrices in. Amet massa vitae tortor condimentum lacinia quis vel eros donec. Et malesuada fames ac turpis egestas integer. Sodales ut eu sem integer vitae justo eget. 2031-07-14 \N f \n \n -598731677.6283197\n variety\n 46234734.5525651\n rising\n -1556052082.582368\n \n eleven\n 1863692621\n -139561185.33627748\n funny\n [{"ago": {"shut": "seven", "found": 469996577.0459976, "climate": "early"}, "scene": "slightly", "medicine": true}, true, true] 3 +87689278 \N -0.31813426 Id donec ultrices tincidunt arcu. Id nibh tortor id aliquet lectus. Condimentum mattis pellentesque id nibh tortor id aliquet lectus proin. Cursus vitae congue mauris rhoncus. Eu ultrices vitae auctor eu augue ut lectus arcu bibendum. Sed turpis tincidunt id aliquet. Feugiat scelerisque varius morbi enim nunc faucibus a pellentesque sit. Diam donec adipiscing tristique risus nec feugiat in fermentum posuere. Scelerisque eu ultrices vitae auctor eu augue ut. Volutpat ac tincidunt vitae semper quis. 1976-12-10 \N t \n rise\n \n consist\n someone\n white\n victory\n -761134241.8632131\n \n 1111641157\n 744054503\n 1876042205.1417785\n {"torn": [false, -1325125579, false], "rising": false, "volume": "grow"} 9 +687527896 \N -1.81914025 Facilisi etiam dignissim diam quis enim. Diam ut venenatis tellus in metus vulputate eu. Mattis rhoncus urna neque viverra justo nec ultrices. Sagittis nisl rhoncus mattis rhoncus urna neque viverra. Nec ullamcorper sit amet risus nullam eget felis eget. Fames ac turpis egestas maecenas pharetra convallis posuere. Eget arcu dictum varius duis at consectetur lorem. Porta lorem mollis aliquam ut porttitor leo a diam sollicitudin. Magna fermentum iaculis eu non diam phasellus vestibulum lorem sed. Etiam non quam lacus suspendisse. Parturient montes nascetur ridiculus mus. Ornare suspendisse sed nisi lacus sed viverra tellus in. Interdum velit euismod in pellentesque massa placerat duis ultricies lacus. Urna nec tincidunt praesent semper feugiat nibh sed pulvinar. 2051-05-16 \N t \n \n 398209907.5902777\n wind\n parallel\n paint\n -1386172501\n \n previous\n skill\n conversation\n keep\n [[-128477882.56726694, 1569798072.8967233, {"us": 438307927.6373253, "think": -870063635, "product": "stuck"}], [{"name": "broad", "took": "brother", "alphabet": -731303259}, [-1065068182.0998564, "finish", "up"], false], false] 5 +8767542 \N 5.08081291 \N Fames ac turpis egestas maecenas. Volutpat lacus laoreet non curabitur gravida arcu ac tortor. Sit amet commodo nulla facilisi nullam vehicula. Ipsum dolor sit amet consectetur adipiscing elit pellentesque. Maecenas ultricies mi eget mauris pharetra. Sed faucibus turpis in eu mi bibendum. Massa ultricies mi quis hendrerit dolor magna. Non diam phasellus vestibulum lorem sed. Vestibulum mattis ullamcorper velit sed ullamcorper morbi tincidunt ornare massa. Massa ultricies mi quis hendrerit dolor magna eget est lorem. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus. 2058-03-29 \N f \n concerned\n -1671936329.7007055\n slept\n how\n -1838021068\n {"basis": "mine", "company": {"tired": false, "prevent": false, "suppose": 735075799}, "worried": {"iron": 378563223.91183805, "nest": false, "raise": {"date": false, "engineer": true, "television": 136840736.65782642}}} 7 +\. + + +-- +-- Data for Name: list_types2; Type: TABLE DATA; Schema: public; Owner: postgres +-- + + + + +-- +-- Data for Name: list_types3; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.list_types3 (integer_type, numeric_type, double_precision_type, varchar_type, text_type, date_type, time_tz_type, boolean_type, xml_type, jsonb_type, id) FROM stdin; +8765542 \N 7.84023409 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vel pretium lectus quam id leo in vitae. Dignissim cras tincidunt lobortis feugiat vivamus at augue. Sit amet aliquam id diam maecenas. Ornare lectus sit amet est placerat in egestas erat. Et malesuada fames ac turpis egestas maecenas pharetra convallis. Orci sagittis eu volutpat odio facilisis. Mauris in aliquam sem fringilla ut morbi tincidunt augue interdum. Nisi porta lorem mollis aliquam ut porttitor leo a diam. Amet purus gravida quis blandit turpis cursus in. Risus feugiat in ante metus. Purus viverra accumsan in nisl nisi scelerisque eu ultrices vitae. Faucibus nisl tincidunt eget nullam. Lectus quam id leo in vitae turpis massa. Nisl nunc mi ipsum faucibus vitae aliquet nec ullamcorper sit. Pretium lectus quam id leo in vitae turpis massa. Blandit aliquam etiam erat velit scelerisque in dictum non. Eu nisl nunc mi ipsum faucibus vitae. 1996-06-15 \N t \n 721744494.7994413\n -26197703.515699387\n event\n \n among\n couple\n official\n spring\n 1032613367\n \n 198858711\n {"truck": 1563128845, "little": -1009907448.0705619, "possible": "gave"} 1 +4562892 \N 5.8024375 \N Massa sapien faucibus et molestie ac. Praesent elementum facilisis leo vel. Turpis egestas pretium aenean pharetra magna. Facilisi cras fermentum odio eu feugiat pretium nibh ipsum consequat. Auctor neque vitae tempus quam pellentesque. Ornare aenean euismod elementum nisi quis eleifend. Purus sit amet luctus venenatis lectus. Tortor consequat id porta nibh venenatis cras sed felis eget. Felis bibendum ut tristique et egestas quis ipsum. Pretium fusce id velit ut tortor pretium viverra. Nam aliquam sem et tortor consequat. Nisl pretium fusce id velit. Sem integer vitae justo eget magna fermentum iaculis. Sit amet nulla facilisi morbi tempus iaculis urna id volutpat. Vitae auctor eu augue ut lectus arcu. Malesuada fames ac turpis egestas. Ac odio tempor orci dapibus ultrices in. Amet massa vitae tortor condimentum lacinia quis vel eros donec. Et malesuada fames ac turpis egestas integer. Sodales ut eu sem integer vitae justo eget. 2031-07-14 \N f \n \n -598731677.6283197\n variety\n 46234734.5525651\n rising\n -1556052082.582368\n \n eleven\n 1863692621\n -139561185.33627748\n funny\n [{"ago": {"shut": "seven", "found": 469996577.0459976, "climate": "early"}, "scene": "slightly", "medicine": true}, true, true] 3 +87689278 \N -0.31813426 Id donec ultrices tincidunt arcu. Id nibh tortor id aliquet lectus. Condimentum mattis pellentesque id nibh tortor id aliquet lectus proin. Cursus vitae congue mauris rhoncus. Eu ultrices vitae auctor eu augue ut lectus arcu bibendum. Sed turpis tincidunt id aliquet. Feugiat scelerisque varius morbi enim nunc faucibus a pellentesque sit. Diam donec adipiscing tristique risus nec feugiat in fermentum posuere. Scelerisque eu ultrices vitae auctor eu augue ut. Volutpat ac tincidunt vitae semper quis. 1976-12-10 \N t \n rise\n \n consist\n someone\n white\n victory\n -761134241.8632131\n \n 1111641157\n 744054503\n 1876042205.1417785\n {"torn": [false, -1325125579, false], "rising": false, "volume": "grow"} 9 +687527896 \N -1.81914025 Facilisi etiam dignissim diam quis enim. Diam ut venenatis tellus in metus vulputate eu. Mattis rhoncus urna neque viverra justo nec ultrices. Sagittis nisl rhoncus mattis rhoncus urna neque viverra. Nec ullamcorper sit amet risus nullam eget felis eget. Fames ac turpis egestas maecenas pharetra convallis posuere. Eget arcu dictum varius duis at consectetur lorem. Porta lorem mollis aliquam ut porttitor leo a diam sollicitudin. Magna fermentum iaculis eu non diam phasellus vestibulum lorem sed. Etiam non quam lacus suspendisse. Parturient montes nascetur ridiculus mus. Ornare suspendisse sed nisi lacus sed viverra tellus in. Interdum velit euismod in pellentesque massa placerat duis ultricies lacus. Urna nec tincidunt praesent semper feugiat nibh sed pulvinar. 2051-05-16 \N t \n \n 398209907.5902777\n wind\n parallel\n paint\n -1386172501\n \n previous\n skill\n conversation\n keep\n [[-128477882.56726694, 1569798072.8967233, {"us": 438307927.6373253, "think": -870063635, "product": "stuck"}], [{"name": "broad", "took": "brother", "alphabet": -731303259}, [-1065068182.0998564, "finish", "up"], false], false] 5 +8767542 \N 5.08081291 \N Fames ac turpis egestas maecenas. Volutpat lacus laoreet non curabitur gravida arcu ac tortor. Sit amet commodo nulla facilisi nullam vehicula. Ipsum dolor sit amet consectetur adipiscing elit pellentesque. Maecenas ultricies mi eget mauris pharetra. Sed faucibus turpis in eu mi bibendum. Massa ultricies mi quis hendrerit dolor magna. Non diam phasellus vestibulum lorem sed. Vestibulum mattis ullamcorper velit sed ullamcorper morbi tincidunt ornare massa. Massa ultricies mi quis hendrerit dolor magna eget est lorem. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus. 2058-03-29 \N f \n concerned\n -1671936329.7007055\n slept\n how\n -1838021068\n {"basis": "mine", "company": {"tired": false, "prevent": false, "suppose": 735075799}, "worried": {"iron": 378563223.91183805, "nest": false, "raise": {"date": false, "engineer": true, "television": 136840736.65782642}}} 7 +\. + + +-- +-- Name: list_types_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.list_types_id_seq', 10, true); + + +-- +-- Name: list_types list_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.list_types + ADD CONSTRAINT list_types_pkey PRIMARY KEY (id); + + +-- +-- PostgreSQL database dump complete +-- + diff --git a/modules/anonymizers/pgsql/pgsql_test.in.sql b/modules/anonymizers/pgsql/.testdata/pgsql_test.in.sql similarity index 100% rename from modules/anonymizers/pgsql/pgsql_test.in.sql rename to modules/anonymizers/pgsql/.testdata/pgsql_test.in.sql diff --git a/modules/anonymizers/pgsql/pgsql_test.out.sql b/modules/anonymizers/pgsql/.testdata/pgsql_test.out.sql similarity index 100% rename from modules/anonymizers/pgsql/pgsql_test.out.sql rename to modules/anonymizers/pgsql/.testdata/pgsql_test.out.sql diff --git a/modules/anonymizers/pgsql/pgsql.go b/modules/anonymizers/pgsql/pgsql.go index 40a6517..bd2edd0 100644 --- a/modules/anonymizers/pgsql/pgsql.go +++ b/modules/anonymizers/pgsql/pgsql.go @@ -143,7 +143,7 @@ func (p *PgSQL) Run(ctx context.Context, w io.Writer) error { Switch: fsm.Switch{ Trigger: []byte("("), Delimiters: fsm.Delimiters{ - R: []byte{'\n'}, + R: []byte{'\n', '\r'}, }, }, DataHandler: dhCreateTableName, @@ -158,7 +158,7 @@ func (p *PgSQL) Run(ctx context.Context, w io.Writer) error { Switch: fsm.Switch{ Trigger: []byte(");"), Delimiters: fsm.Delimiters{ - R: []byte{'\n'}, + R: []byte{'\n', '\r'}, }, }, DataHandler: dhCreateTableDesc, @@ -197,6 +197,13 @@ func (p *PgSQL) Run(ctx context.Context, w io.Writer) error { }, stateCopyTail: { NextStates: []fsm.NextState{ + { + Name: stateTableValues, + Switch: fsm.Switch{ + Trigger: []byte(";\r\n"), + }, + DataHandler: dhTableCopyTail, + }, { Name: stateTableValues, Switch: fsm.Switch{ @@ -214,7 +221,7 @@ func (p *PgSQL) Run(ctx context.Context, w io.Writer) error { Trigger: []byte("\\."), Delimiters: fsm.Delimiters{ L: []byte{'\n'}, - R: []byte{'\n'}, + R: []byte{'\n', '\r'}, }, Escape: false, }, diff --git a/modules/anonymizers/pgsql/pgsql_test.go b/modules/anonymizers/pgsql/pgsql_test.go index 597be9c..569488c 100644 --- a/modules/anonymizers/pgsql/pgsql_test.go +++ b/modules/anonymizers/pgsql/pgsql_test.go @@ -14,7 +14,7 @@ func TestPgSQL(t *testing.T) { var r, e bytes.Buffer - fin, err := os.Open("pgsql_test.in.sql") + fin, err := os.Open(".testdata/pgsql_test.in.sql") if err != nil { t.Fatal("open input SQL:", err) } @@ -63,7 +63,7 @@ func TestPgSQL(t *testing.T) { t.Fatal("run PgSQL:", err) } - fout, err := os.Open("pgsql_test.out.sql") + fout, err := os.Open(".testdata/pgsql_test.out.sql") if err != nil { t.Fatal("open output SQL:", err) } @@ -72,7 +72,78 @@ func TestPgSQL(t *testing.T) { t.Fatal("read output SQL:", err) } - //os.WriteFile("pgsql_test.out.sql", r.Bytes(), 0644) + // os.WriteFile(".testdata/pgsql_test.out.sql", r.Bytes(), 0644) + + if r.String() != e.String() { + t.Fatal("incorrect anonymization result") + } + + t.Logf("success") +} + +func TestPgSQLDos(t *testing.T) { + + var r, e bytes.Buffer + + fin, err := os.Open(".testdata/pgsql_test.dos.in.sql") + if err != nil { + t.Fatal("open input SQL:", err) + } + + m, err := Init( + fin, + InitOpts{ + Rules: RulesOpts{ + TableRules: map[string]map[string]relfilter.ColumnRuleOpts{ + + // Delete only row with id `2` + "public.list_types": { + "integer_type": relfilter.ColumnRuleOpts{ + Type: misc.ValueTypeTemplate, + Value: "{{ if eq .Values.integer_type \"8765542\" }}{{ drop }}{{ else }}{{ .Values.integer_type }}{{ end }}", + Unique: false, + }, + }, + + // Delete all rows from table + "public.list_types2": { + "integer_type": relfilter.ColumnRuleOpts{ + Type: misc.ValueTypeTemplate, + Value: "{{ drop }}", + Unique: false, + }, + }, + + // Delete no rows + "public.list_types3": { + "integer_type": relfilter.ColumnRuleOpts{ + Type: misc.ValueTypeTemplate, + Value: "{{ if eq .Values.integer_type \"0\" }}{{ drop }}{{ else }}{{ .Values.integer_type }}{{ end }}", + Unique: false, + }, + }, + }, + }, + }, + ) + if err != nil { + t.Fatal("init PgSQL:", err) + } + + if err := m.Run(context.Background(), &r); err != nil { + t.Fatal("run PgSQL:", err) + } + + fout, err := os.Open(".testdata/pgsql_test.dos.out.sql") + if err != nil { + t.Fatal("open output SQL:", err) + } + + if _, err := e.ReadFrom(fout); err != nil { + t.Fatal("read output SQL:", err) + } + + // os.WriteFile(".testdata/pgsql_test.dos.out.sql", r.Bytes(), 0644) if r.String() != e.String() { t.Fatal("incorrect anonymization result")