mirror of https://github.com/google/oss-fuzz.git
56 lines
2.2 KiB
Java
56 lines
2.2 KiB
Java
// Copyright 2022 Google LLC
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
//
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
import com.code_intelligence.jazzer.api.FuzzedDataProvider;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.net.URI;
|
|
import java.io.IOException;
|
|
|
|
import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
|
|
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
|
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
|
import org.apache.hc.client5.http.impl.auth.CredentialsProviderBuilder;
|
|
import org.apache.hc.client5.http.auth.CredentialsProvider;
|
|
import org.apache.hc.client5.http.auth.AuthScope;
|
|
import org.apache.hc.client5.http.classic.methods.HttpPost;
|
|
import org.apache.hc.core5.http.ClassicHttpRequest;
|
|
import org.apache.hc.core5.http.message.BasicNameValuePair;
|
|
import org.apache.hc.core5.http.NameValuePair;
|
|
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
|
|
|
|
public class HttpFuzzer {
|
|
public static void fuzzerTestOneInput(FuzzedDataProvider data) {
|
|
final CredentialsProvider credsProvider = CredentialsProviderBuilder.create()
|
|
.add(new AuthScope(data.consumeRemainingAsString(), data.consumeInt()), data.consumeRemainingAsString(), data.consumeRemainingAsString().toCharArray())
|
|
.build();
|
|
|
|
final CloseableHttpClient httpClient = HttpClients.custom()
|
|
.setDefaultCredentialsProvider(credsProvider)
|
|
.build();
|
|
|
|
HttpPost httpPost = new HttpPost("http://localhost");
|
|
List<NameValuePair> nvps = new ArrayList<>();
|
|
nvps.add(new BasicNameValuePair(data.consumeRemainingAsString(), data.consumeRemainingAsString()));
|
|
|
|
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
|
|
|
|
try {
|
|
httpClient.execute(httpPost);
|
|
} catch (IOException e) { }
|
|
}
|
|
} |