[14230] 2019-06-15_Bandit:一款Python代码安全漏洞检测工具

文档创建者:s7ckTeam
浏览次数:14
最后更新:2025-01-18
2019-06-15_Bandit:一款Python代码安全漏洞检测工具 B a n d i t P y t h o n A l p h a _ h 4 c k   F r e e B u f   2 0 1 9 - 0 6 - 1 5 B a n d i t P y t h o n B a n d i t P y t h o n A S T A S T B a n d i t B a n d i t 使 P y P I 广 使 p i p B a n d i t B a n d i t B a n d i t 使 B a n d i t P y P I t a r b a l l 使 使 使 e x a m p l e s / 使 B a n d i t 使 S h e l l I n j e c t i o n e x a m p l e s B a n d i t 使 v i r t u a l e n v   b a n d i t - e n v p i p   i n s t a l l   b a n d i t #   O r   i f   y o u ' r e   w o r k i n g   w i t h   a   P y t h o n   3   p r o j e c t p i p 3   i n s t a l l   b a n d i t b a n d i t   - r   p a t h / t o / y o u r / c o d e p y t h o n   s e t u p . p y   i n s t a l l b a n d i t   - r   ~ / y o u r _ r e p o s / p r o j e c t b a n d i t   e x a m p l e s / * . p y   - n   3   l l l b a n d i t   e x a m p l e s / * . p y   - p   S h e l l I n j e c t i o n
使 使 c a t   e x a m p l e s / i m p o r t s . p y   |   b a n d i t   $ b a n d i t   - h u s a g e : b a n d i t   [ - h ]   [ - r ]   [ - a   { f i l e , v u l n } ]   [ - n   C O N T E X T _ L I N E S ]   [ - c   C O N F I G _ F I L E ]                             [ - p   P R O F I L E ]   [ - t   T E S T S ]   [ - s S K I P S ]   [ - l ]   [ - i ]                             [ - f { c s v , c u s t o m , h t m l , j s o n , s c r e e n , t x t , x m l , y a m l } ]                             [ - - m s g - t e m p l a t e   M S G _ T E M P L A T E ]   [ - o [ O U T P U T _ F I L E ] ]   [ - v ]   [ - d ]   [ - q ]                             [ - - i g n o r e - n o s e c ]   [ - x   E X C L U D E D _ P A T H S ]   [ - b B A S E L I N E ]                             [ - - i n i   I N I _ P A T H ]   [ - - v e r s i o n ]                             [ t a r g e t s   [ t a r g e t s   . . . ] ]   B a n d i t -   a   P y t h o n   s o u r c e   c o d e   s e c u r i t y   a n a l y z e r   p o s i t i o n a l a r g u m e n t s :     t a r g e t s                               s o u r c e   f i l e ( s )   o r   d i r e c t o r y ( s ) t o   b e   t e s t e d   o p t i o n a l a r g u m e n t s :     - h ,   - - h e l p                         s h o w   t h i s   h e l p   m e s s a g e   a n d   e x i t     - r ,   - - r e c u r s i v e               f i n d   a n d   p r o c e s s   f i l e s   i n   s u b d i r e c t o r i e s     - a   { f i l e , v u l n } ,   - - a g g r e g a t e   { f i l e , v u l n }                                                 a g g r e g a t e   o u t p u t   b y v u l n e r a b i l i t y   ( d e f a u l t )   o r   b y                                                 f i l e n a m e     - n   C O N T E X T _ L I N E S ,   - - n u m b e r   C O N T E X T _ L I N E S                                                 m a x i m u m   n u m b e r   o f   c o d e l i n e s   t o   o u t p u t   f o r   e a c h   i s s u e     - c   C O N F I G _ F I L E ,   - - c o n f i g f i l e   C O N F I G _ F I L E                                                 o p t i o n a l   c o n f i g   f i l e   t o u s e   f o r   s e l e c t i n g   p l u g i n s   a n d
                                                o p t i o n a l   c o n f i g   f i l e   t o u s e   f o r   s e l e c t i n g   p l u g i n s   a n d                                                 o v e r r i d i n g   d e f a u l t s     - p   P R O F I L E ,   - - p r o f i l e   P R O F I L E                                                 p r o f i l e   t o   u s e ( d e f a u l t s   t o   e x e c u t i n g   a l l   t e s t s )     - t   T E S T S ,   - - t e s t s   T E S T S                                                 c o m m a - s e p a r a t e d   l i s t   o f t e s t   I D s   t o   r u n     - s   S K I P S ,   - - s k i p   S K I P S                                                 c o m m a - s e p a r a t e d   l i s t   o f t e s t   I D s   t o   s k i p     - l ,   - - l e v e l                       r e p o r t   o n l y   i s s u e s   o f   a   g i v e n s e v e r i t y   l e v e l   o r   h i g h e r                                                 ( - l   f o r   L O W ,   - l l   f o r   M E D I U M ,   - l l l   f o r H I G H )     - i ,   - - c o n f i d e n c e             r e p o r t   o n l y   i s s u e s   o f   a   g i v e n   c o n f i d e n c e l e v e l   o r                                                 h i g h e r   ( - i   f o r   L O W ,   - i i f o r   M E D I U M ,   - i i i   f o r   H I G H )     - f { c s v , c u s t o m , h t m l , j s o n , s c r e e n , t x t , x m l , y a m l } ,   - - f o r m a t { c s v , c u s t o m , h t m l , j s o n , s c r e e n , t x t , x m l , y a m l }                                                 s p e c i f y   o u t p u t   f o r m a t     - - m s g - t e m p l a t e   M S G _ T E M P L A T E                                                 s p e c i f y   o u t p u t   m e s s a g e t e m p l a t e   ( o n l y   u s a b l e   w i t h                                                 - - f o r m a t   c u s t o m ) ,   s e e C U S T O M   F O R M A T   s e c t i o n   f o r   l i s t                                                 o f   a v a i l a b l e   v a l u e s     - o   [ O U T P U T _ F I L E ] ,   - - o u t p u t   [ O U T P U T _ F I L E ]                                                 w r i t e   r e p o r t   t o f i l e n a m e     - v ,   - - v e r b o s e                   o u t p u t   e x t r a   i n f o r m a t i o n   l i k e   e x c l u d e d a n d   i n c l u d e d                                                 f i l e s     - d ,   - - d e b u g                       t u r n   o n   d e b u g   m o d e     - q ,   - - q u i e t ,   - - s i l e n t                                                 o n l y   s h o w   o u t p u t   i n   t h e c a s e   o f   a n   e r r o r     - - i g n o r e - n o s e c                 d o   n o t   s k i p   l i n e s   w i t h   #   n o s e c   c o m m e n t s
    - - i g n o r e - n o s e c                 d o   n o t   s k i p   l i n e s   w i t h   #   n o s e c   c o m m e n t s     - x   E X C L U D E D _ P A T H S ,   - - e x c l u d e   E X C L U D E D _ P A T H S                                                 c o m m a - s e p a r a t e d   l i s t   o f p a t h s   ( g l o b   p a t t e r n s   s u p p o r t e d )                                                 t o   e x c l u d e   f r o m   s c a n ( n o t e   t h a t   t h e s e   a r e   i n   a d d i t i o n                                                 t o   t h e   e x c l u d e d   p a t h s p r o v i d e d   i n   t h e   c o n f i g   f i l e )     - b   B A S E L I N E ,   - - b a s e l i n e   B A S E L I N E                                                 p a t h   o f   a   b a s e l i n e r e p o r t   t o   c o m p a r e   a g a i n s t   ( o n l y                                                 J S O N - f o r m a t t e d   f i l e s a r e   a c c e p t e d )     - - i n i   I N I _ P A T H                 p a t h   t o   a   . b a n d i t   f i l e   t h a t   s u p p l i e s c o m m a n d   l i n e                                                 a r g u m e n t s     - - v e r s i o n                           s h o w   p r o g r a m ' s   v e r s i o n   n u m b e r   a n d e x i t   C U S T O M F O R M A T T I N G - - - - - - - - - - - - - - - - -   A v a i l a b l e t a g s :           { a b s p a t h } ,   { r e l p a t h } ,   { l i n e } ,     { t e s t _ i d } ,         { s e v e r i t y } ,   { m s g } ,   { c o n f i d e n c e } ,   { r a n g e }   E x a m p l e u s a g e :           D e f a u l t   t e m p l a t e :         b a n d i t   - r   e x a m p l e s /   - - f o r m a t   c u s t o m - - m s g - t e m p l a t e           " { a b s p a t h } : { l i n e } :   { t e s t _ i d } [ b a n d i t ] : { s e v e r i t y } :   { m s g } "  
        P r o v i d e s   s a m e   o u t p u t   a s :         b a n d i t   - r   e x a m p l e s /   - - f o r m a t   c u s t o m           T a g s   c a n   a l s o   b e   f o r m a t t e d   i n   p y t h o n   s t r i n g . f o r m a t ( ) s t y l e :         b a n d i t   - r   e x a m p l e s /   - - f o r m a t   c u s t o m - - m s g - t e m p l a t e           " { r e l p a t h : 2 0 . 2 0 s } :   { l i n e : 0 3 } : { t e s t _ i d : ^ 8 } :   D E F E C T :   { m s g : > 2 0 } "           S e e   p y t h o n   d o c u m e n t a t i o n   f o r   m o r e i n f o r m a t i o n   a b o u t   f o r m a t t i n g   s t y l e :         h t t p s : / / d o c s . p y t h o n . o r g / 3 . 4 / l i b r a r y / s t r i n g . h t m l   T h e f o l l o w i n g   t e s t s   w e r e   d i s c o v e r e d   a n d   l o a d e d : - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -       B 1 0 1   a s s e r t _ u s e d     B 1 0 2   e x e c _ u s e d     B 1 0 3   s e t _ b a d _ f i l e _ p e r m i s s i o n s     B 1 0 4   h a r d c o d e d _ b i n d _ a l l _ i n t e r f a c e s     B 1 0 5   h a r d c o d e d _ p a s s w o r d _ s t r i n g     B 1 0 6   h a r d c o d e d _ p a s s w o r d _ f u n c a r g     B 1 0 7   h a r d c o d e d _ p a s s w o r d _ d e f a u l t     B 1 0 8   h a r d c o d e d _ t m p _ d i r e c t o r y     B 1 1 0   t r y _ e x c e p t _ p a s s     B 1 1 2   t r y _ e x c e p t _ c o n t i n u e     B 2 0 1   f l a s k _ d e b u g _ t r u e     B 3 0 1   p i c k l e
    B 3 0 2   m a r s h a l     B 3 0 3   m d 5     B 3 0 4   c i p h e r s     B 3 0 5   c i p h e r _ m o d e s     B 3 0 6   m k t e m p _ q     B 3 0 7   e v a l     B 3 0 8   m a r k _ s a f e     B 3 0 9   h t t p s c o n n e c t i o n     B 3 1 0   u r l l i b _ u r l o p e n     B 3 1 1   r a n d o m     B 3 1 2   t e l n e t l i b     B 3 1 3   x m l _ b a d _ c E l e m e n t T r e e     B 3 1 4   x m l _ b a d _ E l e m e n t T r e e     B 3 1 5   x m l _ b a d _ e x p a t r e a d e r     B 3 1 6   x m l _ b a d _ e x p a t b u i l d e r     B 3 1 7   x m l _ b a d _ s a x     B 3 1 8   x m l _ b a d _ m i n i d o m     B 3 1 9   x m l _ b a d _ p u l l d o m     B 3 2 0   x m l _ b a d _ e t r e e     B 3 2 1   f t p l i b     B 3 2 2   i n p u t     B 3 2 3   u n v e r i f i e d _ c o n t e x t     B 3 2 4   h a s h l i b _ n e w _ i n s e c u r e _ f u n c t i o n s     B 3 2 5   t e m p n a m     B 4 0 1   i m p o r t _ t e l n e t l i b
    B 4 0 2   i m p o r t _ f t p l i b     B 4 0 3   i m p o r t _ p i c k l e     B 4 0 4   i m p o r t _ s u b p r o c e s s     B 4 0 5   i m p o r t _ x m l _ e t r e e     B 4 0 6   i m p o r t _ x m l _ s a x     B 4 0 7   i m p o r t _ x m l _ e x p a t     B 4 0 8   i m p o r t _ x m l _ m i n i d o m     B 4 0 9   i m p o r t _ x m l _ p u l l d o m     B 4 1 0   i m p o r t _ l x m l     B 4 1 1   i m p o r t _ x m l r p c l i b     B 4 1 2   i m p o r t _ h t t p o x y     B 4 1 3   i m p o r t _ p y c r y p t o     B 5 0 1   r e q u e s t _ w i t h _ n o _ c e r t _ v a l i d a t i o n     B 5 0 2   s s l _ w i t h _ b a d _ v e r s i o n     B 5 0 3   s s l _ w i t h _ b a d _ d e f a u l t s     B 5 0 4   s s l _ w i t h _ n o _ v e r s i o n     B 5 0 5   w e a k _ c r y p t o g r a p h i c _ k e y     B 5 0 6   y a m l _ l o a d     B 5 0 7   s s h _ n o _ h o s t _ k e y _ v e r i f i c a t i o n     B 6 0 1   p a r a m i k o _ c a l l s     B 6 0 2   s u b p r o c e s s _ p o p e n _ w i t h _ s h e l l _ e q u a l s _ t r u e     B 6 0 3   s u b p r o c e s s _ w i t h o u t _ s h e l l _ e q u a l s _ t r u e     B 6 0 4   a n y _ o t h e r _ f u n c t i o n _ w i t h _ s h e l l _ e q u a l s _ t r u e     B 6 0 5   s t a r t _ p r o c e s s _ w i t h _ a _ s h e l l     B 6 0 6   s t a r t _ p r o c e s s _ w i t h _ n o _ s h e l l
线 B a n d i t 线 使 线 使 p r e - c o m m i t . p r e - c o m m i t - c o n f i g . y a m l p r e - c o m m i t B a n d i t B a n d i t F o r m a t t e r B a n d i t F o r m a t t e r b a n d i t . c h e c k s A S T     B 6 0 7   s t a r t _ p r o c e s s _ w i t h _ p a r t i a l _ p a t h     B 6 0 8   h a r d c o d e d _ s q l _ e x p r e s s i o n s     B 6 0 9   l i n u x _ c o m m a n d s _ w i l d c a r d _ i n j e c t i o n     B 6 1 0   d j a n g o _ e x t r a _ u s e d     B 6 1 1   d j a n g o _ r a w s q l _ u s e d     B 7 0 1   j i n j a 2 _ a u t o e s c a p e _ f a l s e     B 7 0 2   u s e _ o f _ m a k o _ t e m p l a t e s     B 7 0 3   d j a n g o _ m a r k _ s a f e b a n d i t   - b   B A S E L I N E b a n d i t   - f   j s o n   - o   P A T H _ T O _ O U T P U T _ F I L E r e p o s : -       r e p o :   h t t p s : / / g i t h u b . c o m / P y C Q A / b a n d i t         r e v :   ' '   #   U p d a t e   m e !         h o o k s : -   i d :   b a n d i t b a n d i t . f o r m a t t e r s b a n d i t . p l u g i n s r e s u l t _ s t o r e : b a n d i t . c o r e . B a n d i t R e s u l t S t o r e f i l e _ l i s t : s c o r e s : e x c l u d e d _ f i l e s : @ b a n d i t . c h e c k s ( ' C a l l ' )
B a n d i t 1   使 s e t u p t o o l s s e t u p 2   使 p b r s e t u p . c f g h t t p s : / / b a n d i t . r e a d t h e d o c s . i o / e n / l a t e s t / B a n d i t h t t p s : / / g i t h u b . c o m / P y C Q A / b a n d i t h t t p s : / / g i t h u b . c o m / P y C Q A / b a n d i t / i s s u e s @ b a n d i t . c h e c k s ( ' C a l l ' ) d e f p r o h i b i t _ u n s a f e _ d e s e r i a l i z a t i o n ( c o n t e x t ) :         i f   ' u n s a f e _ l o a d '   i n c o n t e x t . c a l l _ f u n c t i o n _ n a m e _ q u a l :                 r e t u r n   b a n d i t . I s s u e (                         s e v e r i t y = b a n d i t . H I G H ,                         c o n f i d e n c e = b a n d i t . H I G H ,                         t e x t = " U n s a f e   d e s e r i a l i z a t i o n d e t e c t e d . "                 ) #   I f y o u   h a v e   a n   i m a g i n a r y   b s o n   f o r m a t t e r   i n   t h e   b a n d i t _ b s o n   m o d u l e #   a n d a   f u n c t i o n   c a l l e d   ` f o r m a t t e r ` . e n t r y _ p o i n t s = { ' b a n d i t . f o r m a t t e r s ' : [ ' b s o n   =   b a n d i t _ b s o n : f o r m a t t e r ' ] } #   O r a   c h e c k   f o r   u s i n g   m a k o   t e m p l a t e s   i n   b a n d i t _ m a k o   t h a t e n t r y _ p o i n t s = { ' b a n d i t . p l u g i n s ' : [ ' m a k o   =   b a n d i t _ m a k o ' ] } [ e n t r y _ p o i n t s ] b a n d i t . f o r m a t t e r s =         b s o n =   b a n d i t _ b s o n : f o r m a t t e r b a n d i t . p l u g i n s =         m a k o   =   b a n d i t _ m a k o
A p a c h e * b a n d i t F B A l p h a _ h 4 c k F r e e B u f . C O M
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则