<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Arshia Rahbari</title>
    <description>The latest articles on DEV Community by Arshia Rahbari (@20acoder12).</description>
    <link>https://dev.to/20acoder12</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3950188%2F210602fe-ba8f-43cf-b915-e4b9d92862bc.jpg</url>
      <title>DEV Community: Arshia Rahbari</title>
      <link>https://dev.to/20acoder12</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/20acoder12"/>
    <language>en</language>
    <item>
      <title>How to use bandit library?</title>
      <dc:creator>Arshia Rahbari</dc:creator>
      <pubDate>Fri, 05 Jun 2026 17:19:43 +0000</pubDate>
      <link>https://dev.to/20acoder12/how-to-use-bandit-library-2e2c</link>
      <guid>https://dev.to/20acoder12/how-to-use-bandit-library-2e2c</guid>
      <description>&lt;p&gt;Bandit is a static analysis tool for finding common security issues in Python code. It is easy to use and does not require any changes to your source code. Simply run it from the terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Here we have a tutorial on basic functions of bandit PYPI library:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;First we add the package to our project similar to other python libraries:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;bandit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Then to scan a single app, go to the root of your project and write (both Win and MC):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bandit your_app_name.py 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To scan all the files in the root folder of your project:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bandit &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;You can save result of bandit test in a JSON or HTML file:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;for JSON:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bandit &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; json &lt;span class="nt"&gt;-o&lt;/span&gt; bandit-report.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;for HTML:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bandit &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; html &lt;span class="nt"&gt;-o&lt;/span&gt; bandit-report.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;If you have folders like test or venv that you want bandit to don't check them, you can use:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bandit &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-x&lt;/span&gt; tests,venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Notice:&lt;/strong&gt; The commands work the same on Windows and macOS.&lt;/p&gt;

&lt;p&gt;If you have any questions and problems, please leave a comment!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>python</category>
      <category>bandit</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
