jdaugherty commented on code in PR #16631:
URL: https://github.com/apache/grails-core/pull/16631#discussion_r4390361455


##########
grails-datamapping-core/src/main/groovy/org/apache/grails/datamapping/core/querytail/StandardSqlSyntax.groovy:
##########
@@ -0,0 +1,310 @@
+/*
+ *  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
+ *
+ *    https://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.
+ */
+package org.apache.grails.datamapping.core.querytail
+
+import groovy.transform.CompileStatic
+import groovy.transform.PackageScope
+
+/**
+ * The rules of standard SQL, which every database shares: a single-quoted 
string in which the
+ * quote is written twice, a double-quoted name in which the quote is written 
twice, a number, a
+ * {@code --} comment to the end of the line, and a {@code /* ... *}{@code /} 
comment that does not
+ * nest. The syntax of a database extends it and overrides the hooks its 
database differs on.
+ */
+@CompileStatic
+@PackageScope
+abstract class StandardSqlSyntax implements QueryTailSyntax {
+
+    private static final char SPACE = ' '
+    private static final char ZERO = '0'
+    private static final char NINE = '9'
+    private static final char LOWER_A = 'a'
+    private static final char LOWER_Z = 'z'
+    private static final char UPPER_A = 'A'
+    private static final char UPPER_Z = 'Z'
+    private static final char UNDERSCORE = '_'
+    private static final char ASCII_LAST = 0x7F as char
+
+    private final String name
+
+    protected StandardSqlSyntax(String name) {
+        this.name = name
+    }
+
+    @Override
+    int endOfComment(String sql, int index) {
+        if (sql.startsWith('/*', index)) {
+            return endOfBlockComment(sql, index)
+        }
+        if (sql.startsWith('--', index)) {
+            return endOfLine(sql, index)
+        }
+        NONE
+    }
+
+    @Override
+    int endOfValue(String sql, int index) {
+        char c = sql.charAt(index)
+        if (c == '\'') {
+            return endOfString(sql, index)
+        }
+        if (c == '"' && doubleQuotedStrings()) {
+            return endOfQuoted(sql, index, '"' as char, backslashEscapes(), 
true)
+        }
+        if (startsNumber(sql, index) && standalone(sql, index)) {
+            return endOfNumber(sql, index)
+        }
+        NONE
+    }
+
+    @Override
+    int endOfQuotedName(String sql, int index) {

Review Comment:
   Fixed in b8f737d030. A password is not always a literal: Oracle takes the 
one `IDENTIFIED BY` gives as a name, quoted or bare, and SAP HANA takes a 
user's `PASSWORD` the same way. So the redactor now withholds a statement that 
gives a password, whole and on every database:
   - one with `IDENTIFIED BY`, including when a comment or line break splits 
the two words;
   - one that creates or alters a user, role or login and gives it a `PASSWORD`;
   - one that starts with `CONNECT`, since Db2's `CONNECT ... USING` takes a 
bare password too.
   
   Your statement is asserted withheld, quoted and bare, with 
`ExampleSecret123` absent from the file:
   - `QueryTailRedactorSpec`: withheld rows for Oracle (quoted, bare, 
`REPLACE`, a comment between `IDENTIFIED` and `BY`, role and database-link 
passwords, and before the database is known), SAP HANA, Db2, MySQL, PostgreSQL 
and Neo4j.
   - `QueryTailCaptureSpec`: the capture file.
   
   A `password` column in a query, Oracle's `CONNECT BY` and table DDL are 
still recorded as before.
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to