ocket8888 commented on a change in pull request #5913:
URL: https://github.com/apache/trafficcontrol/pull/5913#discussion_r651125189
##########
File path: docs/source/admin/traffic_vault.rst
##########
@@ -79,6 +79,53 @@ Administration of the PostgreSQL database for Traffic Vault
Similar to administering the Traffic Ops database, the :ref:`admin
<database-management>` tool should be used for administering the PostgreSQL
Traffic Vault backend.
+.. program:: reencrypt
+
+app/db/reencrypt/reencrypt
+--------------------------
+The :program:`reencrypt` binary is used to re-encrypt all data in the Postgres
Traffic Vault with a new base64-encoded AES key.
+
+.. note:: For proper resolution of configuration files, it's recommended that
this binary be run from the ``app/db/reencrypt`` directory.
+
+Usage
+"""""
+``./reencrypt [options]``
+
+Options and Arguments
+"""""""""""""""""""""
+.. option:: --new-key NEW_KEY
+
+ (Optional) The file path for the new base64-encoded AES key. Default is
``/opt/traffic_ops/app/conf/new.key``.
+
+.. option:: --previous-key PREVIOUS_KEY
+
+ (Optional) The file path for the previous base64-encoded AES key.
Default is ``/opt/traffic_ops/app/conf/aes.key``.
+
+.. option:: --cfg CONFIG_FILE
+
+ (Optional) The path for the configuration file. Default is
``./reencrypt.conf``.
+
+.. option:: --help
+
+ (Optional) Print usage information and exit.
+
+.. code-block:: bash
+ :caption: Example Usage
+
+ ./reencrypt --new-key ~/exampleNewKey.txt --previous-key
~/exampleOldKey.txt
+
+reencrypt.conf
+""""""""""""""
+This file deals with configuration of the Traffic Vault Database to be used
with the :program:`reencrypt` tool.
+
+:dbname: The name of the PostgreSQL database used.
+:hostname: The hostname (:abbr:`FQDN (Fully Qualified Domain Name)`) of the
server that runs the Traffic Vault Database.
+:password: The password to use when authenticating with the Traffic Vault
database.
+:port: The port number (as a string) on which the Traffic Vault Database is
listening for incoming connections (NOTE: the PostgreSQL default is 5432).
+:ssl: A boolean that sets whether or not the Traffic Vault Database encrypts
its connections with SSL.
+:user: The name of the user as whom to connect to the database.
+
+
Review comment:
This all looks correct. Unfortunately, due to things you didn't change,
the docs are having some issues:
```
docs/source/admin/traffic_vault.rst#L172
Title level inconsistent:
```
etc.
The problem is that the existing structure is using:
```rst
**************
Document Title
**************
Section Header
==============
Subsection Header
-----------------
Sub-subsection Header
^^^^^^^^^^^^^^^^^^^^^
Aside
"""""
```
which isn't following the guidelines I linked in my last review. You can
either change your <kbd>"</kbd> heading underlines to <kbd>^</kbd>, or fix the
document to conform to the guidelines. The document should be updated, but it's
not related to the work your doing, so you don't have to.
##########
File path: traffic_ops/app/db/reencrypt/reencrypt.go
##########
@@ -0,0 +1,370 @@
+/*
+
+Name
+ reencrypt
+
+Synopsis
+ reencrypt [--previous-key value] [--new-key value] [--cfg value]
+
+Description
+ The reencrypt app is used to re-encrypt all data in the Postgres Traffic
Vault
+ using a new base64-encoded AES key.
+
+Options
+ --previous-key
+ The file path for the previous base64-encoded AES key.
+
+ --new-key
+ The file path for the new base64-encoded AES key.
+
+ --cfg
+ The path for the configuration file. Default is `./reencrypt.conf`.
+
+*/
+
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+ "crypto/aes"
+ "database/sql"
+ "encoding/base64"
+ "encoding/json"
+ "errors"
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "time"
+
+ "github.com/apache/trafficcontrol/lib/go-util"
+
+ "github.com/jmoiron/sqlx"
+ _ "github.com/lib/pq"
+)
+
+const PROPERTIES_FILE = "./reencrypt.conf"
+
+func main() {
+ previousKeyLocation := flag.String("previous-key",
"/opt/traffic_ops/app/conf/aes.key", "(Optional) The file path for the previous
base64 encoded AES key. Default is /opt/traffic_ops/app/conf/aes.key.")
+ newKeyLocation := flag.String("new-key",
"/opt/traffic_ops/app/conf/new.key", "(Optional) The file path for the new
base64 encoded AES key. Default is /opt/traffic_ops/app/conf/new.key.")
+ cfg := flag.String("cfg", PROPERTIES_FILE, "(Optional) The path for the
configuration file. Default is "+PROPERTIES_FILE+".")
+ help := flag.Bool("help", false, "(Optional) Print usage information
and exit.")
+ flag.Parse()
+
+ if *help {
+ flag.Usage()
+ os.Exit(1)
Review comment:
if they request usage with `--help` and the program prints it
successfully, I don't think it should exit with a failure.
##########
File path: docs/source/admin/traffic_vault.rst
##########
@@ -79,6 +79,53 @@ Administration of the PostgreSQL database for Traffic Vault
Similar to administering the Traffic Ops database, the :ref:`admin
<database-management>` tool should be used for administering the PostgreSQL
Traffic Vault backend.
+.. program:: reencrypt
+
+app/db/reencrypt/reencrypt
+--------------------------
+The :program:`reencrypt` binary is used to re-encrypt all data in the Postgres
Traffic Vault with a new base64-encoded AES key.
+
+.. note:: For proper resolution of configuration files, it's recommended that
this binary be run from the ``app/db/reencrypt`` directory.
+
+Usage
+"""""
+``./reencrypt [options]``
+
+Options and Arguments
+"""""""""""""""""""""
+.. option:: --new-key NEW_KEY
+
+ (Optional) The file path for the new base64-encoded AES key. Default is
``/opt/traffic_ops/app/conf/new.key``.
+
+.. option:: --previous-key PREVIOUS_KEY
+
+ (Optional) The file path for the previous base64-encoded AES key.
Default is ``/opt/traffic_ops/app/conf/aes.key``.
+
+.. option:: --cfg CONFIG_FILE
+
+ (Optional) The path for the configuration file. Default is
``./reencrypt.conf``.
+
+.. option:: --help
+
+ (Optional) Print usage information and exit.
+
+.. code-block:: bash
+ :caption: Example Usage
+
+ ./reencrypt --new-key ~/exampleNewKey.txt --previous-key
~/exampleOldKey.txt
Review comment:
looks like there's an extra space here before `./reencrypt`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]