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

Help wanted !!! There is a bug that needs your attention, thanks in advance! #201

Closed
yuandongx opened this issue Jan 8, 2021 · 4 comments

Comments

@yuandongx
Copy link

yuandongx commented Jan 8, 2021

SUMMARY

I have missed a bug with code bock when I run a command access-list test-acl-1 extended permit tcp object-group IP_Test host 10.22.5.38 eq 8080, and IP_Test does not exist on my device. An exception wiil be raised, but not.
The reason of which is that length of error message is too long to handle with method _find_prompt.
The method will only handle a block with length less than 256, but with length more than 256, error_response will be None again.So the network_cli will not work well.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

plugins/connection/network_cli.py

ANSIBLE VERSION

CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS

@yuandongx
Copy link
Author

yuandongx commented Jan 12, 2021

 def _find_prompt(self, response):
        """Searches the buffered response for a matching command prompt
        """
        errored_response = None
        is_error_message = False

        for stderr_regex in self._terminal_stderr_re:
            if stderr_regex.search(response):
                is_error_message = True
                self._log_messages(
                    "matched error regex (terminal_stderr_re) '%s' from response '%s'"
                    % (stderr_regex.pattern, response)
                )
                # Check if error response ends with command prompt if not
                # receive it buffered prompt
                for stdout_regex in self._terminal_stdout_re:
                    match = stdout_regex.search(response)
                    if match:
                        errored_response = response
                        self._matched_pattern = stdout_regex.pattern
                        self._matched_prompt = match.group()
                        self._log_messages(
                            "matched stdout regex (terminal_stdout_re) '%s' from error response '%s'"
                            % (self._matched_pattern, errored_response)
                        )
                        break
                else:
                    self._log_messages(
                        "Ignoring matched error regex (terminal_stderr_re) '%s' from response '%s' as the cli prompt is not in the same response"
                        % (stderr_regex.pattern, response)
                    )
                if errored_response:

These Lines

          for stdout_regex in self._terminal_stdout_re:
                    match = stdout_regex.search(response)
                    if match:
                        errored_response = response

Regex will not match response and errored_response will still be None, when an error message length is more than 255.
Becase _find_prompt recevied no more than 256 chars, and next response fragment have no error: regexp.

@yuandongx yuandongx changed the title A bug will come out when an error message has length more than 256. Help wanted !!! There is a bug that needs your attention, thanks in advance! Jan 12, 2021
@yuandongx
Copy link
Author

Maybe relate to ansible-collections/cisco.asa#83

@yuandongx
Copy link
Author

@Qalthos
Copy link
Collaborator

Qalthos commented Jan 12, 2021

This appears to be a duplicate of #16. Thanks for reminding us that this really needs to get fixed

@Qalthos Qalthos closed this as completed Jan 12, 2021
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

No branches or pull requests

2 participants