-1
If Request.QueryString("ID") = "" Then
                folderDirectory = Global.FileUpload.GetFolderDirectory(Request.QueryString("TFID"))

                If Not File.Exists(folderDirectory + fileName) Then
                    If Not Directory.Exists(folderDirectory) Then
                        Directory.CreateDirectory(folderDirectory)
                    End If

                    Dim bufferSize As Integer = Me.fileUpload.PostedFile.ContentLength
                    Dim buffer As Byte() = New Byte(bufferSize) {}
                    '  write the byte to disk
                    Using fs As New FileStream(Path.Combine(folderDirectory, fileName), FileMode.Create)
                        Dim bytes As Integer = Me.fileUpload.PostedFile.InputStream.Read(buffer, 0, bufferSize)
                        '  write the bytes to the file stream
                        fs.Write(buffer, 0, bytes)
                    End Using
                Else
                    CallOnComplete("error", "", "Error uploading '" & fileName & "'. File has been exists!")
                    Exit Sub
                End If

しかし、上記のサンプルコードのFortifyスキャンレポートは、Path Manipulation問題が高いことを示しています。要塞スキャンに合格できるように上記のコードを変更するのに助けが必要ですfolderDirectoryでエラーが表示されます

4

1 に答える 1

1

通常、コードがWebアプリケーション内で機能する場合、ローカルPCで行うように完全なファイルシステムを使用する自由はありません。あらゆる種類の「パス操作」は疑わしいものです。Server.MapPathメソッドを使用して作品を再コーディングしてみてください。この警告に特に注意してください

For security reasons, the AspEnableParentPaths property has a default value set to FALSE.  
Scripts will not have access to the physical directory structure unless AspEnableParentPaths  
is set to TRUE.
于 2012-04-20T07:48:48.973 に答える