File tree Expand file tree Collapse file tree
src/experimental/Security/CWE-022bis
test/experimental/query-tests/Security/CWE-022 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,8 +46,14 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
4646 )
4747 or
4848 // A source download a file using wget
49- exists ( MethodCallNode mcn |
50- mcn = API:: moduleImport ( "wget" ) .getMember ( "download" ) .getACall ( ) and source = mcn .getArg ( 1 )
49+ // see wget: https://pypi.org/project/wget/
50+ exists ( API:: CallNode mcn |
51+ mcn = API:: moduleImport ( "wget" ) .getMember ( "download" ) .getACall ( ) and
52+ (
53+ source = mcn .getArg ( 1 )
54+ or
55+ source = mcn .getReturn ( ) .asSource ( ) and not exists ( Node arg | arg = mcn .getArg ( 1 ) )
56+ )
5157 )
5258 or
5359 // catch the uploaded files as a source
Original file line number Diff line number Diff line change 5959# A source catching an S3 filename download
6060# see boto3: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.download_file
6161import boto3
62+ import os
6263
6364remote_ziped_name = "remote_name.tar.gz"
6465base_dir = "/tmp/basedir"
6768
6869s3 = boto3 .client ('s3' )
6970s3 .download_file (bucket_name , remote_ziped_name , local_ziped_path )
70- shutil .unpack_archive (local_ziped_path , base_dir ) # $result=BAD
71+ shutil .unpack_archive (local_ziped_path , base_dir ) # $result=BAD
72+
73+
74+ # wget
75+ # see wget: https://pypi.org/project/wget/
76+ import wget
77+ import os
78+
79+ url = "https://some.remote/location/remote_name.tar.xz"
80+ compressed_file = "/tmp/basedir/local_name.tar.xz"
81+ base_dir = "/tmp/basedir"
82+
83+ # download(url, out, bar) contains out parameter
84+ wget .download (url , compressed_file )
85+ shutil .unpack_archive (compressed_file , base_dir ) # $result=BAD
86+
87+ # download(url) returns filename
88+ compressed_file = wget .download (url )
89+ shutil .unpack_archive (compressed_file , base_dir ) # $result=BAD
You can’t perform that action at this time.
0 commit comments