0

ベンダー (現在は取引を行っていません) が作成した e ラーニング コースを利用していますが、自社のセキュリティ ソフトウェア (HP Fortify Scan) を介してファイルをアップロードすると、複数のエラーが発生します。1 つを除いてすべてのエラーを修正しました。エラーは dojo.js ファイルにあり、url変数が検証されていないことに関係しています。簡単な修正だと思いますが、これが検証されていない理由を誰かが説明できますか? urlそして、この変数をどのように検証できますか?

コード付きのエラー メッセージのスクリーン ショットを次に示します (行番号をコメントに入れました)。

Fortify スキャンのスクリーンショット

コード:

function xhr(url, options, returnDeferred){
    var response = util.parseArgs(
        url,
        util.deepCreate(defaultOptions, options),
        has('native-formdata') && options && options.data && options.data instanceof FormData
    );
    // THIS IS LINE 11540
    url = response.url; 
    options = response.options;

    var remover,
        last = function(){
            remover && remover();
        };

    //Make the Deferred object for this xhr request.
    var dfd = util.deferred(
        response,
        cancel,
        isValid,
        isReady,
        handleResponse,
        last
    );
    var _xhr = response.xhr = xhr._create();

    if(!_xhr){
        // If XHR factory somehow returns nothings,
        // cancel the deferred.
        dfd.cancel(new RequestError('XHR was not created'));
        return returnDeferred ? dfd : dfd.promise;
    }

    response.getHeader = function(headerName){
        return this.xhr.getResponseHeader(headerName);
    };

    if(addListeners){
        remover = addListeners(_xhr, dfd, response);
    }

    var data = options.data,
        async = !options.sync,
        method = options.method;

    try{
        // IE6 won't let you call apply() on the native function.
        // THIS IS LINE 11580
        _xhr.open(method, url, async, options.user || undefined, options.password || undefined);

        if(options.withCredentials){
            _xhr.withCredentials = options.withCredentials;
        }

        var headers = options.headers,
            contentType;
        if(headers){
            for(var hdr in headers){
                if(hdr.toLowerCase() === 'content-type'){
                    contentType = headers[hdr];
                }else if(headers[hdr]){
                    //Only add header if it has a value. This allows for instance, skipping
                    //insertion of X-Requested-With by specifying empty value.
                    _xhr.setRequestHeader(hdr, headers[hdr]);
                }
            }
        }

        if(contentType && contentType !== false){
            _xhr.setRequestHeader('Content-Type', contentType);
        }
        if(!headers || !('X-Requested-With' in headers)){
            _xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
        }

        if(util.notify){
            util.notify.emit('send', response, dfd.promise.cancel);
        }
        _xhr.send(data);
    }catch(e){
        dfd.reject(e);
    }

    watch(dfd);
    _xhr = null;

    return returnDeferred ? dfd : dfd.promise;
}

前もって感謝します、

マイク

4

1 に答える 1

0

これは必ずしもエラーではないと思います。サーバー コードがそのようなエラーに対して準備されていない場合に備えて、注意が必要な dojo/request/xhr.js 内のコードを HP Fortify Scan が指摘しているだけです。攻撃... xhr() を呼び出すアプリケーション (おそらくストア内) のより高いレベルのコードで URL を検証することができますが、それが HP Fortify を満たすかどうかはわかりません。

于 2015-01-12T01:07:07.893 に答える