Skip to content
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

Update db2_data_source.py #2063

Merged
merged 6 commits into from
Apr 23, 2024
Merged

Update db2_data_source.py #2063

merged 6 commits into from
Apr 23, 2024

Conversation

4rahulae
Copy link
Contributor

This is needed in order to fix the connectivity issues for db2 from soda-core.

Please add this change as part of the soda-core release

This is needed in order to fix the connectivity issues for db2 from soda-core
@CLAassistant
Copy link

CLAassistant commented Apr 18, 2024

CLA assistant check
All committers have signed the CLA.

@4rahulae
Copy link
Contributor Author

4rahulae commented Apr 18, 2024

once the approvals are done and the changes are approved, how soon can this be added to the new release?

Copy link
Contributor Author

@4rahulae 4rahulae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes look good to me, adding this self.verify_ssl = data_source_properties.get("security") in line 68 and updating conn_str in line 72 or 73 as below
conn_str = f"DATABASE={self.database};HOSTNAME={self.host};PORT={self.port};UID={self.username};PWD={self.password};SECURITY={self.verify_ssl}"

@4rahulae
Copy link
Contributor Author

@m1n0 @vijaykiran Hi Milan as per our discussions earlier can you please review this PR and approve it and merge it for release?

@dirkgroenen
Copy link
Contributor

Hi @4rahulae, thanks for your contribution 🙌 @m1n0 is currently traveling back from our company offsite, so he'll likely not reach out today.

I'm myself not able to test this at the moment, but could you assist by verifying that your changes do not impact configurations where security is not set? According to the documentation I can see that it only accepts SSL as a valid value, so I would like to make sure this does not introduce backwards compatability issues for anyone who does not define security in their configuration.yml.

(For example a possible scenario could be that Python translates it into an empty string or None, triggering DB2 to fail)

@4rahulae
Copy link
Contributor Author

4rahulae commented Apr 19, 2024

Hi @dirkgroenen i did verify the backward compatibility by not defining security in the configuration.yml and the scan doesn't fail except that it returns with a message "[IBM][CLI Driver] SQL30081N A communication error has been detected" which only applies to my use case and after adding security: SSL it works. I believe in other scenarios when security is not defined it will default to None or empty string and if defining security is not needed it should still work

@m1n0
Copy link
Contributor

m1n0 commented Apr 22, 2024

thanks for the contrib @4rahulae ! I would suggest a bit more conservative way to do this though - pythons get without a second param returns NULL, so the VERIFY_SSL= will contain nothing, I would suggest only appending it to the connection string if it does have a non-null value, would you agree?
Also, I think it would make sense to match the yaml key we read with the connection string argument, so read verify_ssl instead of security if that makes sense.

@4rahulae
Copy link
Contributor Author

Hi @m1n0 are you suggesting doing something like below?.

self.verify_ssl = data_source_properties.get("verify_ssl","SSL")
conn_str = (
f"DATABASE={self.database};HOSTNAME={self.host};PORT={self.port};UID={self.username};PWD={self.password};SECURITY={self.verify_ssl}.

This way there is no need to define security in the config file , i have tested this and it works.
Without passing security either in the config or in db2_data_source.py as shown above I'm unable to connect to db2.

Please suggest if you have other ways to make this work as of right now i see this is the only other option that works apart from the suggested option earlier as part of pull request?

@m1n0
Copy link
Contributor

m1n0 commented Apr 23, 2024

hi, I don't know what the default value for SECURITY is, so maybe I would suggest a more safe/generic way to do this:

self.security = data_source_properties.get("security")

conn_str =  f"DATABASE={self.database};HOSTNAME={self.host};PORT={self.port};UID={self.username};PWD={self.password}"

if self.security is not None:
  conn_str += f";SECURITY={self.security}"

what do you think?

4rahulae and others added 3 commits April 23, 2024 15:27
adding security as part of the config for db2, security will be added to the connection string only when it is not empty. This is needed in order to establish a connection with db2
remove security from the 1st connection string
@4rahulae
Copy link
Contributor Author

4rahulae commented Apr 23, 2024

Hi @m1n0 added changes as per your suggestion and tested them successfully on my local, please review the changes and let me know if it looks good to be merged and added for release?

@m1n0
Copy link
Contributor

m1n0 commented Apr 23, 2024

Thanks for the contrib, merging!

@m1n0 m1n0 merged commit 34ace6a into sodadata:main Apr 23, 2024
11 of 14 checks passed
Copy link

sonarcloud bot commented Apr 23, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

tombaeyens pushed a commit that referenced this pull request Apr 26, 2024
* Update db2_data_source.py

This is needed in order to fix the connectivity issues for db2 from soda-core

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update db2_data_source.py

adding security as part of the config for db2, security will be added to the connection string only when it is not empty. This is needed in order to establish a connection with db2

* Update db2_data_source.py

remove security from the 1st connection string

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Milan Lukac <m1n0@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants