You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/06/10 14:41:35 UTC

[GitHub] [trafficcontrol] mattjackson220 commented on a change in pull request #5913: Re-encrypt Tool for TV Postgres

mattjackson220 commented on a change in pull request #5913:
URL: https://github.com/apache/trafficcontrol/pull/5913#discussion_r649250021



##########
File path: traffic_ops/app/db/reencrypt/reencrypt.go
##########
@@ -0,0 +1,393 @@
+/*
+
+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"
+	"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", "", "The file path for the previous base64 encoded AES key.")
+	newKeyLocation := flag.String("new-key", "", "The file path for the new base64 encoded AES key.")
+	cfg := flag.String("cfg", PROPERTIES_FILE, "The path for the configuration file. Default is "+PROPERTIES_FILE+".")
+	flag.Parse()
+
+	if len(os.Args) < 4 {
+		flag.Usage()
+		os.Exit(1)
+	}
+
+	if previousKeyLocation == nil || *previousKeyLocation == "" {
+		die("previous-key flag is required.")
+	}
+	if newKeyLocation == nil || *newKeyLocation == "" {
+		die("new-key flag is required.")
+	}

Review comment:
       that was my thinking too especially since the inputs will be so similar i like having the flags to indicate which is which. but i added in defaults so we can still have the flags and also have them really be optional




-- 
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:
users@infra.apache.org