“It takes 20 years to build a reputation and few minutes of cyber-incident to ruin it.” ― Stephane Nappo
Secure coding practice is one of the best ways of coding practice, which helps developers to prevent applications from cybersecurity vulnerabilities and exploits. Developers really encouraged to integrate secure coding practice into their day-to-day operations and development lifecycle and it includes Software Security Principles. Below are the comprises of software security principle categories that provide good knowledge,
- Minimize attack surface area.
- Establish secure defaults.
- The principle of Least Privilege
- The principle of Defense in depth
- Fail securely
- Don’t trust services
- Separation of duties
- Avoid security by obscurity
- Keep security simple
- Fix security issues correctly
One of the largest online community Stack overflow Annual Developer Survey 2018 tells the world most wanted language is Python(25.1%). As per impreva study, more than 20% of Github repositories that have python based attack tools, exploits, and Proof of Concepts. More than 77% of applications are globally attacked by python based tools and It’s really good to know that hackers are well known with python programming.
What if hackers hacked developers code(python based codes)? Maybe open source code or hacked from any other repositories. Easily hackers can read and understands the application’s code and able to find the loopholes from the applications. If developers follow secure coding guidelines, this might prevent applications from various hacking attacks done by hackers.
“ code is communication.” ― unknown
Below are the General coding style guidelines are highly recommended to follow python programmers,
- PEP-0257 - python officially recommends to follow the high-level docstring conventions. This describes how the classes, functions, and codes should be documented? and how this really helps for code readability?.
- PEP-3101 - This is the new system for built-in string formatting operations, intended as a replacement for the existing ‘%’ string formatting operator.
- PEP-0008 - python coding style guidelines which strongly recommend naming conventions, comments, formatting and lot more...
- GPSG - Google Python Style Guideline talks about do’s and don'ts for python programs and it explains technically with proof and concepts.
- Python Anti-Patterns - provides anti-pattern with a technical explanation of best practices and it covers anti-pattern for Django framework also.
- The Hitchhikers Guide to Python - the book written by Kenneth and Tany, I would strongly encourage python programmers to read, this book covers lots of recommended best practices from the section called Writing Great Python Code.
We can get lots of recommended resources and best style guideline practices from the internet. Unfortunately, we have very few resources which talk about Secure coding guidelines.
- OWASP(Open Web Application Security) - python security is an open source OSWAP project. This project has security concerns in python web applications and also it enables security concerns in python modules and functionalities.
- Bandit - is a tool designed to find common security issues in Python code and it’s Originally developed by OpenStack Security later it’s moved to PyCQA - (Python Code Quality of Authority).
After lots of research bandit is the tool I found to scan my code, which covers some of the OWASP 10, this project has very clear documentation and proper error code details.
General Coding guidelines and Secure Coding guidelines are really important for programmers to follow.
Thanks for Reading… check out my other blog Ansible — Contributing Python Modules(Part-1).