Skip to content

Commit f11477f

Browse files
Semgrep Showcase
1 parent ef04b8d commit f11477f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

semgrep/example.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os, sys # F401: sys imported but unused
2+
3+
def my_function( x, y ):
4+
print( "Result:",x+y ) # E201, E202, E231, E221
5+
6+
class myclass: # N801: class name should use CapWords convention
7+
def __init__(self):
8+
self.value =42 # E225: missing whitespace around operator
9+
10+
def doSomething(self): # N802: function name should be snake_case
11+
if( self.value>0 ):
12+
print("Positive")
13+
else:
14+
print( "Not positive" )
15+
16+
my_function(1,2)

semgrep/semgrep.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
rules:
2+
- id: hardcoded-password
3+
pattern: password = "$SECRET"
4+
message: "Avoid hardcoded passwords"
5+
severity: ERROR
6+
languages: [python]
7+
metadata:
8+
category: security

0 commit comments

Comments
 (0)