Skip to content

Commit e95ed65

Browse files
committed
Fix code blocks in docs
1 parent 63f3bcb commit e95ed65

File tree

3 files changed

+73
-33
lines changed

3 files changed

+73
-33
lines changed

README.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ every session start for restricted users. This can be accomplished by configurin
2828
For example, to automatically load the `pg_diffix` extension for all users connecting to a database,
2929
you can execute the following command:
3030

31-
`ALTER DATABASE db_name SET session_preload_libraries TO 'pg_diffix';`
31+
```
32+
ALTER DATABASE db_name SET session_preload_libraries TO 'pg_diffix';
33+
```
3234

3335
Once loaded, the extension logs information to `/var/log/postgresql/postgresql-13-main.log` or equivalent.
3436

@@ -42,7 +44,9 @@ You might also need to remove the extension from the list of preloaded libraries
4244

4345
For example, to reset the list of preloaded libraries for a database, you can execute the following command:
4446

45-
`ALTER DATABASE db_name SET session_preload_libraries TO DEFAULT;`
47+
```
48+
ALTER DATABASE db_name SET session_preload_libraries TO DEFAULT;
49+
```
4650

4751
## Testing the extension
4852

@@ -61,7 +65,10 @@ or if available, just make your usual PostgreSQL user a `SUPERUSER`.
6165

6266
Or you can use the [PGXN Extension Build and Test Tools](https://github.com/pgxn/docker-pgxn-tools) Docker image:
6367

64-
`docker run -it --rm --mount "type=bind,src=$(pwd),dst=/repo" pgxn/pgxn-tools sh -c 'cd /repo && apt update && apt install -y jq && pg-start 13 && pg-build-test'`.
68+
```
69+
docker run -it --rm --mount "type=bind,src=$(pwd),dst=/repo" pgxn/pgxn-tools sh -c \
70+
'cd /repo && apt update && apt install -y jq && pg-start 13 && pg-build-test'
71+
```
6572

6673
## Docker images
6774

@@ -76,15 +83,21 @@ The example below shows how to build the image and run a minimally configured co
7683

7784
Build the image:
7885

79-
`make image`
86+
```
87+
make image
88+
```
8089

8190
Run the container in foreground and expose in port 10432:
8291

83-
`docker run --rm --name pg_diffix -e POSTGRES_PASSWORD=postgres -p 10432:5432 pg_diffix`
92+
```
93+
docker run --rm --name pg_diffix -e POSTGRES_PASSWORD=postgres -p 10432:5432 pg_diffix
94+
```
8495

8596
From another shell you can connect to the container via `psql`:
8697

87-
`psql -h localhost -p 10432 -d postgres -U postgres`
98+
```
99+
psql -h localhost -p 10432 -d postgres -U postgres
100+
```
88101

89102
For more advanced usage see the [official image reference](https://hub.docker.com/_/postgres).
90103

@@ -102,16 +115,25 @@ Three users are created, all of them with password `demo`:
102115

103116
Build the image:
104117

105-
`make demo-image`
118+
```
119+
make demo-image
120+
```
106121

107122
Run the container in foreground and expose in port 10432:
108123

109-
`docker run --rm --name pg_diffix_demo -e POSTGRES_PASSWORD=postgres -e BANKING_PASSWORD=demo -p 10432:5432 pg_diffix_demo`
124+
```
125+
docker run --rm --name pg_diffix_demo -e POSTGRES_PASSWORD=postgres -e BANKING_PASSWORD=demo -p 10432:5432 pg_diffix_demo
126+
```
110127

111128
Connect to the banking database (from another shell) for anonymized access:
112129

113-
`psql -h localhost -p 10432 -d banking -U trusted_user`
130+
```
131+
psql -h localhost -p 10432 -d banking -U trusted_user
132+
```
114133

115134
To keep the container running you can start it in detached mode and with a restart policy:
116135

117-
`docker run -d --name pg_diffix_demo --restart unless-stopped -e POSTGRES_PASSWORD=postgres -e BANKING_PASSWORD=demo -p 10432:5432 pg_diffix_demo`
136+
```
137+
docker run -d --name pg_diffix_demo --restart unless-stopped \
138+
-e POSTGRES_PASSWORD=postgres -e BANKING_PASSWORD=demo -p 10432:5432 pg_diffix_demo
139+
```

docs/admin_guide.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Trusted users have fewer SQL restrictions than untrusted users, and therefore ha
3636

3737
For example, the command to assign the access level `anonymized_untrusted` to the role `public_access` is:
3838

39-
```SQL
39+
```
4040
CALL diffix.mark_role('public_access', 'anonymized_untrusted');
4141
```
4242

@@ -69,12 +69,12 @@ __NOTE:__ if AID columns are not correctly labeled, the extension may fail to an
6969
The procedure `diffix.mark_personal(table_name, aid_columns...)` is used to label a table as personal and
7070
to label its AID columns. For example:
7171

72-
```SQL
72+
```
7373
CALL diffix.mark_personal('employee_info', 'employee_id');
7474
```
7575
labels the table `employee_info` as personal, and labels the `employee_id` column as an AID column.
7676

77-
```SQL
77+
```
7878
CALL diffix.mark_personal('transactions', 'sender_acct', 'receiver_acct');
7979
```
8080
labels the table `transactions` as personal, and labels the `sender_acct` and `receiver_acct` columns as AID columns.
@@ -186,7 +186,7 @@ Given that AIDs may not be perfect, some care must be taken in the selection of
186186

187187
For example, imagine the following query in a table where `account_number` is the AID column:
188188

189-
```sql
189+
```
190190
SELECT last_name, religion, count(*)
191191
FROM table
192192
GROUP BY last_name, religion

docs/admin_tutorial.md

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,70 @@ containing a column named `id`, which uniquely identifies protected entities (th
88

99
## Installation
1010

11-
1. Install the packages required for building the extension:
11+
1\. Install the packages required for building the extension:
1212

13-
`sudo apt-get install make jq gcc postgresql-server-dev-14`
13+
```
14+
sudo apt-get install make jq gcc postgresql-server-dev-14
15+
```
1416

15-
2. Install PGXN Client tools:
17+
2\. Install PGXN Client tools:
1618

17-
`sudo apt-get install pgxnclient`
19+
```
20+
sudo apt-get install pgxnclient
21+
```
1822

19-
3. Install the extension:
23+
3\. Install the extension:
2024

21-
`sudo pgxn install pg_diffix`
25+
```
26+
sudo pgxn install pg_diffix
27+
```
2228

2329
## Activation
2430

25-
1. Connect to the database as a superuser:
31+
1\. Connect to the database as a superuser:
2632

27-
`sudo -u postgres psql test_db`
33+
```
34+
sudo -u postgres psql test_db
35+
```
2836

29-
2. Activate the extension for the current database:
37+
2\. Activate the extension for the current database:
3038

31-
`CREATE EXTENSION pg_diffix;`
39+
```
40+
CREATE EXTENSION pg_diffix;
41+
```
3242

33-
3. Automatically load the extension for all users connecting to the database:
43+
3\. Automatically load the extension for all users connecting to the database:
3444

35-
`ALTER DATABASE test_db SET session_preload_libraries TO 'pg_diffix';`
45+
```
46+
ALTER DATABASE test_db SET session_preload_libraries TO 'pg_diffix';
47+
```
3648

3749
## Configuration
3850

39-
1. Label the test data as personal (requiring anonymization):
51+
1\. Label the test data as personal (requiring anonymization):
4052

41-
`CALL diffix.mark_personal('test_table', 'id');`
53+
```
54+
CALL diffix.mark_personal('test_table', 'id');
55+
```
4256

43-
2. Create an account for the analyst:
57+
2\. Create an account for the analyst:
4458

45-
`CREATE USER analyst_role WITH PASSWORD 'some_password';`
59+
```
60+
CREATE USER analyst_role WITH PASSWORD 'some_password';
61+
```
4662

47-
3. Give the analyst read-only access to the test database:
63+
3\. Give the analyst read-only access to the test database:
4864

4965
```
5066
GRANT CONNECT ON DATABASE test_db TO analyst_role;
5167
GRANT SELECT ON ALL TABLES IN SCHEMA public TO analyst_role;
5268
```
5369

54-
4. Label the analyst as restricted and trusted:
70+
4\. Label the analyst as restricted and trusted:
5571

56-
`CALL diffix.mark_role('analyst_role', 'anonymized_trusted');`
72+
```
73+
CALL diffix.mark_role('analyst_role', 'anonymized_trusted');
74+
```
5775

5876

5977
__That's it!__ The analyst can now connect to the database and issue (only) anonymizing queries against the test dataset.

0 commit comments

Comments
 (0)