350-201 exam dumps

350-201 practice question 242 of 289

Cybersecurity Professional - Performing Cybersecurity Using Cisco Security Technologies. Professional level, Cisco. Free question with the correct answer and a full explanation.

350-201 Question 242

Select 3

You are tasked with analyzing a Python script used to automate the retrieval of security logs from a Cisco Secure Firewall. The script contains the following snippet:

import requests

url = 'https://firewall.example.com/api/logs'
headers = {'Authorization': 'Bearer <token>'}
response = requests.get(url, headers=headers)

if response.status_code == 200:
    logs = response.json()
    for log in logs:
        print(log['timestamp'], log['event'])
elif response.status_code == 401:
    print('Authentication failed: Invalid token')
else:
    print('Error:', response.status_code)

Which of the following statements about the script's functionality are correct?

  1. A

    The script uses the requests library to send a GET request to the firewall's API.

  2. B

    The script will raise an exception if the server responds with a 401 status code.

  3. C

    The script retrieves logs in JSON format if the API responds with a status code of 200.

  4. D

    The script outputs an error message for any non-200 or non-401 status codes.

  5. E

    The script ensures secure communication by verifying the SSL certificate of the API endpoint.

Show answer and explanation

Correct answers: A, C, D

Explanation

This Python script is used to retrieve security logs from a Cisco Secure Firewall API. It uses the requests library to send a GET request, handles various HTTP status codes (200 for success, 401 for authentication failure, and others as generic errors), and processes the logs in JSON format. However, it does not explicitly address SSL certificate verification, which is a critical consideration in secure communications.

  • A. Correct.

    Correct. The script uses the requests.get() function with a specified URL and headers to retrieve data from the firewall's API.

  • B. Incorrect.

    Incorrect. The script handles a 401 status code explicitly and prints an authentication failure message. It does not raise an exception in this case.

  • C. Correct.

    Correct. The script processes the response as JSON if the status code is 200, as indicated by the response.json() function.

  • D. Correct.

    Correct. For any status code that is neither 200 nor 401, the script outputs an error message with the status code.

  • E. Incorrect.

    Incorrect. There is no explicit mention in the script of SSL certificate verification, and the requests library by default does not enforce certificate validation unless explicitly configured.

Timed practice exam

Take a 350-201 practice test under exam conditions

75 questions in 120 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam