Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python is a popular programming language and has been labeled as having a safe core. However; specific code implementation can lead to risky and vulnerable

Python is a popular programming language and has been labeled as having a safe core. However; specific code implementation can lead to risky and vulnerable applications. Bandit is a tool that can be used to check existing code in your Cloud9 IDE for possible vulnerabilities.

For example, the following code (albeit maybe not that useful) has a potential concern as the exception is not logged. Instead we just continue.

print ('Hello from Python 3')

count=0 while count<5: try: count+=1 print(str(count)) except Exception: continue

If you run bandit on the directory on this code, you will receive this message:

Test results: >> Issue: [B112:try_except_continue] Try, Except, Continue detected. Severity: Low Confidence: High Location: SDEV300/Hello.py:12 More Info: https://bandit.readthedocs.io/en/latest/plugins/b112_try_except_continue.html 11 print(str(count)) 12 except Exception: 13 continue

You can install bandit in your Cloud9 Environment using this syntax at the shell:

sudo python3 -m pip install bandit

You can run bandit using this syntax at the shell:

bandit -r path/to/file/

where path/to/file/ is the location of your files.

For this exercise, use the bandit test plug-in listing found at the URL below to write your own Python code snippet that would cause an issue to be displayed.

https://bandit.readthedocs.io/en/latest/plugins/index.html

Pick something that another student has not selected. For example, you could generate an issue related to B110: try_except_pass.

For your interaction portion, use the Python code another student submitted and run it in your environment. Identify the error and provide a possible mitigation.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

What is the function of master data management (MDM)?

Answered: 1 week ago

Question

What are the critical issues in a hierarchical team organization?

Answered: 1 week ago