New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/urlparser improve3 pr2 #2646
base: master
Are you sure you want to change the base?
Conversation
|
GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
---|---|---|---|---|---|
- | PostgreSQL Credentials | 464f9b9 | pgjdbc/src/test/java/org/postgresql/jdbcurlresolver/JdbcUrlResolverTest.java | View secret | |
- | Generic Password | 464f9b9 | pgjdbc/src/test/java/org/postgresql/jdbcurlresolver/JdbcUrlResolverTest.java | View secret | |
- | Generic Password | 464f9b9 | pgjdbc/src/test/java/org/postgresql/jdbcurlresolver/JdbcUrlResolverTest.java | View secret | |
- | PostgreSQL Credentials | 464f9b9 | pgjdbc/src/test/java/org/postgresql/jdbcurlresolver/JdbcUrlResolverTest.java | View secret | |
- | Generic Password | 464f9b9 | pgjdbc/src/test/resources/pg_service/pgservicefileProps.conf | View secret | |
- | Generic Password | 464f9b9 | pgjdbc/src/test/java/org/postgresql/jdbcurlresolver/JdbcUrlResolverTest.java | View secret | |
- | Generic Database Assignment | 464f9b9 | pgjdbc/src/test/java/org/postgresql/jdbcurlresolver/JdbcUrlResolverTest.java | View secret | |
- | Generic Password | 464f9b9 | pgjdbc/src/test/resources/pg_service/pgservicefileProps.conf | View secret | |
- | Generic Password | 464f9b9 | pgjdbc/src/test/java/org/postgresql/jdbcurlresolver/JdbcUrlResolverTest.java | View secret | |
- | Generic Password | 464f9b9 | pgjdbc/src/test/java/org/postgresql/jdbcurlresolver/JdbcUrlResolverTest.java | View secret | |
- | Generic Password | 464f9b9 | pgjdbc/src/test/java/org/postgresql/jdbcurlresolver/JdbcUrlResolverTest.java | View secret | |
- | Generic Password | 464f9b9 | pgjdbc/src/test/java/org/postgresql/jdbcurlresolver/JdbcUrlResolverTest.java | View secret | |
- | Generic Password | 464f9b9 | pgjdbc/src/test/java/org/postgresql/jdbcurlresolver/JdbcUrlResolverTest.java | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
if (resourceName == null) { | ||
return null; | ||
} | ||
// | ||
String result = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are looking to provide psql compatibility we should probably check the permissions of the file to ensure they are 0600 on *nix systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good observation. Permission check is added: https://github.com/pgjdbc/pgjdbc/compare/581edc3..736f2cb
@davecramer |
@MarekUniq currently my plans are 1) merge in the issue with longs #2710 will be reopened and merged. A release with this fix will be released. I would hold off rebasing until after the above happens. Thanks for your patience |
@davecramer |
@davecramer Hi! What are merge plans? |
Is there any progress on merging this? |
I'm generally in favour of this PR. It will need to be rebased. |
} | ||
|
||
private void verifyUrl(Driver drv, String url, String hosts, String ports, String dbName) | ||
private void verifyUrl(Driver drv, String url, String hosts, String ports, String dbName, String user, @Nullable String pass) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding an overload for the old private verifyUrl(...)
to call the new one?
private void verifyUrl(Driver drv, String url, String hosts, String ports, String dbName) {
verifyUrl(drv, url, hosts, ports, dbName, "osUser", null);
}
That way the majority of the above test cases would not duplicate that info and it would better showcase that none of the expected behavior for those tests have changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate info removed: c7413f7
|
@MarekUniq , the change reads |
@vlsi - I agree that GitHub displayed this PR in a strange way. I saw it too. (was it a glitch or my mistake, I do not know) But I noticed there were 5 new commits in |
@MarekUniq , please rebase commits so they appear "on top of the master branch". The project uses linear history rather than merge commits. |
README.md
Outdated
| Property | Type | Default | Description | | ||
|-------------------------------| -- |:---------------------------------------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| user | String | `operating system username` | The database user on whose behalf the connection is being made. | | ||
| password | String | null | The database user's password. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the full table appears to be changed?
Can we please avoid re-formatting the table with every commit that touches it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please just change the lines you want to change. Keep the reset intact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original spaces restored with commit: 0eac4e3
README.md
Outdated
| pgjdbc.config.cleanup.thread.ttl | long | 30000 | | The driver has an internal cleanup thread which monitors and cleans up unclosed connections. This property sets the duration (in milliseconds) the cleanup thread will keep running if there is nothing to clean up. | | ||
|
||
#### Operating System Environment variables | ||
The following environment variables can be set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "env vars can be set" mean? What does it give to the end users?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is about improving compatibility with libpq
What does "env vars can be set" mean?
# An example of setting environment variables:
export PGUSER=my_user
export PGPASSWORD=my_password
What does it give to the end users?
# then jdbc and libpq-based programs can be launched identically:
java ... MainJdbcBasedProgram
./main_libpq_based_program
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is that it would be better to phrase the features in terms of their usability.
The fact that environment variable can be set does not provide much to the end users.
It might be better to have something like "Some of the settings could be passed from environment variables as follows:..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it good enough: 3db232a
* @deprecated Use property HOST instead | ||
*/ | ||
@Deprecated | ||
PG_HOST( | ||
"PGHOST", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens to the code that still uses PGHOST
and PGPORT
properties? Will it continue to work? Where's the corresponding test case?
case OTHERS_READ: | ||
case OTHERS_WRITE: | ||
case OTHERS_EXECUTE: | ||
LOGGER.log(Level.WARNING, "password file [{0}] has group or world access; permissions should be u=rw (0600) or less", new Object[]{fileName}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we log the current value along with the desired one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current value is logged now: a81210d
@@ -1465,10 +1465,10 @@ public void setProperty(PGProperty property, @Nullable String value) { | |||
return; | |||
} | |||
switch (property) { | |||
case PG_HOST: | |||
case HOST: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a backward incompatible change. Old code might still call setProperty(PGProperty.PG_HOST, ...)
and it should continue to work as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for finding!
Added fix and test case in commit: 4b29449
/** | ||
* routines to support PG properties | ||
*/ | ||
public class PGPropertyUtil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class removal is a backward-incompatible change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In broad terms, you are correct. However, this class was intended for internal use only. It is not a JDBC driver service provided for external clients.
I can restore this class (and optionally mar methods as deprecated).
What are your expectations here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class was public, so people might be using it. We must maintain backward compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class is restored and marked as deprecated
The key question I have here is how do we test and ensure backward compatibility? |
@vlsi I think I can't change the order of commits anymore. |
What do you mean by "can't change the order of commits"? Could you please squash at your side? |
24c5eba
to
464f9b9
Compare
@vlsi Is this the result you were expecting? I did the following:
|
d73adc9
to
464f9b9
Compare
1. Compatibility with libpq is improved regarding URL syntax and resolving url values
1.1.
user
andpassword
are supportedComplete syntax:
jdbc:postgresql://[[user][:password]@][host1[:port1][,host2[:port2]][,...]][/database][?property1=value1[&property2=value2][&...]]
URL may include:
user
(Optional) is the user to connect. Defaults to operating system username.password
(Optional) is the password to connect. No default value.1.2. property
passfile
is supportedExample:
1.3. Code is more clear regarding Properties override rules (source and result are logged at FINE logging level)
There are multiple sources for connection properties. If same property is specified in multiple sources then highest priority source is used. Priority list is here:
1.4. References
Related to: #2260 #2278 #2398 #2393 #2395 #2424 #2569 #2641 #2644
All Submissions:
New Feature Submissions:
./gradlew autostyleCheck checkstyleAll
pass ?Changes to Existing Features: