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

SNMP hardening - redis socket connect #281

Closed

Conversation

ycoheNvidia
Copy link

- What I did
in order to support snmp container hardening in sonic-net/sonic-buildimage#15176
Made snmp agent to communicate with redis using socket
- How I did it
Added the use of socket connection to redis during snmp agent init

- How to verify it
Configure and run snmp
- Description for the changelog
Added the use of socket connection to redis during snmp agent init

Getting use_unix_socket_path value as argument instead of default True
@qiluo-msft
Copy link
Contributor

Could you add unit test to cover the code change?

@@ -211,6 +211,8 @@ def split_sai_id_key(sai_id_key):
def config(**kwargs):
global redis_kwargs
redis_kwargs = {k:v for (k,v) in kwargs.items() if k in ['unix_socket_path', 'host', 'port']}
if 'unix_socket_path' in redis_kwargs and 'host' in redis_kwargs and 'port' in redis_kwargs:
redis_kwargs['use_unix_socket_path'] = True
Copy link
Contributor

@SuvarnaMeenakshi SuvarnaMeenakshi Oct 9, 2023

Choose a reason for hiding this comment

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

what happens if unix_socket_path or host is not present in redis_kwargs?
I see that with master branch image, redis_kwargs only has 'decode_responses' and with that the connection to redis fails.
If I add "use_unix_socket_path" to true in redis_kwargs, then the connection is successful and snmp_subagent comes up. Can you re-check if this works as expected ?

@SuvarnaMeenakshi SuvarnaMeenakshi self-requested a review October 9, 2023 22:10
@ycoheNvidia
Copy link
Author

Could you add unit test to cover the code change?

We had a discussion about it few months ago, is there infra for it?

@qiluo-msft
Copy link
Contributor

Could you write a unit test for function def config(**kwargs)? Just parsing some args and check value of global redis_kwargs.


In reply to: 1759423882

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.

3 participants