Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 38 additions & 24 deletions eng/CredScanSuppression.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,40 @@
"suppressions": [
{
"placeholder": [
"secret=",
"123",
"1234567890",
"((***Redacted***by***CredScan***))",
"proxyPassword",
"pass",
"dummyPassword",
"P@ssw0rd",
"12NewPA$$w0rd!",
"Samp1eP@ssw0rd",
"facebookapplicationsecret",
"updatedfacebooksecret",
"serverappsecret"
],
"_justification": "Secret used by test code, it is fake."
"_justification": "Secret used by jackson json property and test code, it is fake."
},
{
"placeholder": "*sig=sD3fPKLnFKZUjnSV4qA%2FXoJOqsmDfNfxWcZ7kPtLc0I%3D*",
"_justification": "Base-64 encoded SHA-256 of a placeholder above."
},
{
"placeholder": "95o6TL9jkIjNr6HurD6Xa+zLQ+PX9/VWR8fI2ofHatbrUb8kRJ75B6enwRU3q1OP8fmjghaoxdqnwhN7m3pZow=",
"_justification": "Well-known Account Key"
"placeholder": [
"administratorLoginPassword"
],
"_justification": "Secret used by spring-cloud-azure-integration-tests/test-resources/jdbc/mysql/test-resources.json"
},
{
"placeholder": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"_justification": "SHA-256 encrypted random data generated at test time."
},
{
"placeholder": "JdppJP5eH1w/CQ0cx4RGYWoC7NmQ0nmDbYR2PYWSDTXojV9bI1ck0Eh0sUIg8xj4KYj7tv+ZPLICu3BgLt6mMz==",
"_justification": "Mocked key used in performance testing."
},
{
"placeholder": "OAuth2ClientCredential",
"_justification": "Javadoc in azure-resourcemanager-datafactory"
},
{
"file":[
"placeholder": [
"h2PermissionGrants",
"h2PermissionScopes"
],
"_justification": "Javadoc in azure-resourcemanager"
},
{
"placeholder": [
"h2AllowImplicitFlow",
"h2Permissions"
],
"_justification": "Javadoc in azure resourcemanagerhybrid"
},
{
"file": [
"eng/common/testproxy/dotnet-devcert.pfx",
"sdk/cosmos/azure-cosmos/src/test/resources/server.jks",
"sdk/cosmos/azure-cosmos/src/test/resources/client.jks",
Expand All @@ -57,6 +53,24 @@
"sdk/keyvault/microsoft-azure-keyvault-cryptography/src/test/resources/secp256keynew.pem"
],
"_justification": "File contains private key used by test code."
},
{
"file": [
"sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/FakeCredentialConstants.java"
],
"_justification": "File contains fake key used by implementation code."
},
{
"file": [
"sdk/communication/azure-communication-common-perf/src/main/java/com.azure.communication.common.perf/FakeCredentialInTest.java",
"sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/FakeCredentialInTest.java",
"sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/FakeCredentialInTest.java",
"sdk/spring/spring-cloud-azure-service/src/test/java/com/azure/spring/cloud/service/implementation/storage/FakeCredentialInTest.java",
"sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/FakeCredentialInTest.java",
"sdk/storage/azure-storage-common/src/test/java/com/azure/storage/common/FakeCredentialInTest.java",
"sdk/storage/microsoft-azure-storage-blob/src/test/java/com/microsoft/azure/storage/FakeCredentialInTest.groovy"
],
"_justification": "File contains fake key used by test code."
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* Base class for Anomaly Detector clients test.
*/
public class AnomalyDetectorClientTestBase extends TestBase {
private static final String FAKE_API_KEY = "1234567890";
private static final String FAKE_API_KEY = "fakeKeyPlaceholder";
Comment thread
mssfang marked this conversation as resolved.
private static final String OCP_APIM_SUBSCRIPTION_KEY = "Ocp-Apim-Subscription-Key";

void testDetectEntireSeriesWithResponse(Consumer<DetectRequest> testRunner) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6444,7 +6444,7 @@ public final class IdentityProviderCreateOrUpdateSamples {
.define(IdentityProviderType.FACEBOOK)
.withExistingService("rg1", "apimService1")
.withClientId("facebookid")
.withClientSecret("facebookapplicationsecret")
.withClientSecret("fakeSecretPlaceholder")
.create();
}
}
Expand Down Expand Up @@ -6597,7 +6597,7 @@ public final class IdentityProviderUpdateSamples {
resource
.update()
.withClientId("updatedfacebookid")
.withClientSecret("updatedfacebooksecret")
.withClientSecret("fakeUpdatedSecretPlaceholder")
.withIfMatch("*")
.apply();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void apiManagementCreateIdentityProvider(
.define(IdentityProviderType.FACEBOOK)
.withExistingService("rg1", "apimService1")
.withClientId("facebookid")
.withClientSecret("facebookapplicationsecret")
.withClientSecret("fakeSecretPlaceholder")
.create();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void apiManagementUpdateIdentityProvider(
resource
.update()
.withClientId("updatedfacebookid")
.withClientSecret("updatedfacebooksecret")
.withClientSecret("fakeUpdatedSecretPlaceholder")
.withIfMatch("*")
.apply();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.util.Map;
import java.util.stream.Collectors;

import static com.azure.data.appconfiguration.implementation.FakeCredentialConstants.SECRET_PLACEHOLDER;

/**
* Credentials that authorizes requests to Azure App Configuration. It uses content within the HTTP request to
* generate the correct "Authorization" header value. {@link ConfigurationCredentialsPolicy} ensures that the content
Expand Down Expand Up @@ -156,7 +158,7 @@ private void addSignatureHeader(final URL url, final String httpMethod, final Ma
private static class CredentialInformation {
private static final String ENDPOINT = "endpoint=";
private static final String ID = "id=";
private static final String SECRET = "secret=";
private static final String SECRET = SECRET_PLACEHOLDER;

private final URL baseUri;
private final String id;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.data.appconfiguration.implementation;

/**
* Never explore this class publicly. It should be only use in internal to gather the fake credential or keyword that
* failed the CredScan.
*/
public final class FakeCredentialConstants {
/**
* 'secret=' keyword placeholder.
*/
public static final String SECRET_PLACEHOLDER = "secret=";
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ public void testDeserialize() {
RegistryInfo model =
BinaryData
.fromString(
"{\"registryUrl\":\"klnsrmffey\",\"registryUserName\":\"ckt\",\"registryPassword\":\"ymerteeammxq\"}")
"{\"registryUrl\":\"fakeUrlPlaceholder\",\"registryUserName\":\"fakeNamePlaceholder\",\"registryPassword\":\"fakePasswordPlaceholder\"}")
.toObject(RegistryInfo.class);
Assertions.assertEquals("klnsrmffey", model.registryUrl());
Assertions.assertEquals("ckt", model.registryUsername());
Assertions.assertEquals("ymerteeammxq", model.registryPassword());
Assertions.assertEquals("fakeUrlPlaceholder", model.registryUrl());
Assertions.assertEquals("fakeNamePlaceholder", model.registryUsername());
Assertions.assertEquals("fakePasswordPlaceholder", model.registryPassword());
}

@Test
public void testSerialize() {
RegistryInfo model =
new RegistryInfo()
.withRegistryUrl("klnsrmffey")
.withRegistryUsername("ckt")
.withRegistryPassword("ymerteeammxq");
.withRegistryUrl("fakeUrlPlaceholder")
.withRegistryUsername("fakeNamePlaceholder")
.withRegistryPassword("fakePasswordPlaceholder");
model = BinaryData.fromObject(model).toObject(RegistryInfo.class);
Assertions.assertEquals("klnsrmffey", model.registryUrl());
Assertions.assertEquals("ckt", model.registryUsername());
Assertions.assertEquals("ymerteeammxq", model.registryPassword());
Assertions.assertEquals("fakeUrlPlaceholder", model.registryUrl());
Assertions.assertEquals("fakeNamePlaceholder", model.registryUsername());
Assertions.assertEquals("fakePasswordPlaceholder", model.registryPassword());
}
}
4 changes: 2 additions & 2 deletions sdk/automation/azure-resourcemanager-automation/SAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3938,7 +3938,7 @@ public final class SourceControlCreateOrUpdateSamples {
.withSourceType(SourceType.VSO_GIT)
.withSecurityToken(
new SourceControlSecurityTokenProperties()
.withAccessToken("3a326f7a0dcd343ea58fee21f2fd5fb4c1234567")
.withAccessToken("fakeTokenPlaceholder")
.withTokenType(TokenType.PERSONAL_ACCESS_TOKEN))
.withDescription("my description")
.create();
Expand Down Expand Up @@ -4041,7 +4041,7 @@ public final class SourceControlUpdateSamples {
.withPublishRunbook(true)
.withSecurityToken(
new SourceControlSecurityTokenProperties()
.withAccessToken("3a326f7a0dcd343ea58fee21f2fd5fb4c1234567")
.withAccessToken("fakeTokenPlaceholder")
.withTokenType(TokenType.PERSONAL_ACCESS_TOKEN))
.withDescription("my description")
.apply();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void createOrUpdateASourceControl(com.azure.resourcemanager.automa
.withSourceType(SourceType.VSO_GIT)
.withSecurityToken(
new SourceControlSecurityTokenProperties()
.withAccessToken("3a326f7a0dcd343ea58fee21f2fd5fb4c1234567")
.withAccessToken("fakeTokenPlaceholder")
Comment thread
mssfang marked this conversation as resolved.
.withTokenType(TokenType.PERSONAL_ACCESS_TOKEN))
.withDescription("my description")
.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void updateASourceControl(com.azure.resourcemanager.automation.Aut
.withPublishRunbook(true)
.withSecurityToken(
new SourceControlSecurityTokenProperties()
.withAccessToken("3a326f7a0dcd343ea58fee21f2fd5fb4c1234567")
.withAccessToken("fakeTokenPlaceholder")
.withTokenType(TokenType.PERSONAL_ACCESS_TOKEN))
.withDescription("my description")
.apply();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.communication.common.perf;

/**
* Fake credential list.
*/
public final class FakeCredentialInTest {
/**
* Fake Azure Key Credential for mocking.
*/
public static final String MOCK_KEY_PLACEHOLDER =
"JdppJP5eH1w/CQ0cx4RGYWoC7NmQ0nmDbYR2PYWSDTXojV9bI1ck0Eh0sUIg8xj4KYj7tv+ZPLICu3BgLt6mMz==";
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.ConcurrentHashMap;

import static com.azure.communication.common.perf.FakeCredentialInTest.MOCK_KEY_PLACEHOLDER;

/**
* HmacAuthenticationPolicyTest is designed to verify the correctness of the calculation
* of the request signature header in the HmacAuthenticationPolicy in a race condition.
Expand All @@ -21,9 +24,7 @@
public class HmacAuthenticationPolicyTest extends PerfStressTest<PerfStressOptions> {

private final static ConcurrentHashMap<String, String> dateToSignature = new ConcurrentHashMap<>();
// Do not change this otherwise CredScan will flag this.
private final static String mockedKey = "JdppJP5eH1w/CQ0cx4RGYWoC7NmQ0nmDbYR2PYWSDTXojV9bI1ck0Eh0sUIg8xj4KYj7tv+ZPLICu3BgLt6mMz==";
private final static HmacAuthenticationPolicy hmacAuthenticationPolicy = new HmacAuthenticationPolicy(new AzureKeyCredential(mockedKey));
private final static HmacAuthenticationPolicy hmacAuthenticationPolicy = new HmacAuthenticationPolicy(new AzureKeyCredential(MOCK_KEY_PLACEHOLDER));

private final HttpPipeline pipeline;
private final HttpRequest request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public class CteTestHelper {
private static final String COMMUNICATION_M365_REDIRECT_URI = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_M365_REDIRECT_URI", "Sanitized");
private static final String COMMUNICATION_MSAL_USERNAME = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_MSAL_USERNAME", "Sanitized");
.get("COMMUNICATION_MSAL_USERNAME", "fakeUsernamePlaceholder");
private static final String COMMUNICATION_MSAL_PASSWORD = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_MSAL_PASSWORD", "Sanitized");
.get("COMMUNICATION_MSAL_PASSWORD", "fakePasswordPlaceholder");
private static final String COMMUNICATION_EXPIRED_TEAMS_TOKEN = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_EXPIRED_TEAMS_TOKEN", "Sanitized");
private static final String COMMUNICATION_SKIP_INT_IDENTITY_EXCHANGE_TOKEN_TEST = Configuration.getGlobalConfiguration()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void testFlowableBackpressure() {
public void testRequestBodyIsErrorShouldPropagateToResponse() {
HttpClient client = new JdkHttpClientProvider().createInstance();
HttpRequest request = new HttpRequest(HttpMethod.POST, url(server, "/shortPost"))
.setHeader("Content-Length", "123")
.setHeader("Content-Length", "132")
.setBody(Flux.error(new RuntimeException("boo")));

StepVerifier.create(client.send(request))
Expand Down Expand Up @@ -318,7 +318,7 @@ public void testStreamUploadAsync() throws IOException {
public void testRequestBodyIsErrorShouldPropagateToResponseSync() {
HttpClient client = new JdkHttpClientProvider().createInstance();
HttpRequest request = new HttpRequest(HttpMethod.POST, url(server, "/shortPost"))
.setHeader("Content-Length", "123")
.setHeader("Content-Length", "132")
.setBody(Flux.error(new RuntimeException("boo")));

UncheckedIOException thrown = assertThrows(UncheckedIOException.class, () -> client.sendSync(request, Context.NONE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public void testFlowableBackpressure() {
public void testRequestBodyIsErrorShouldPropagateToResponse() {
HttpClient client = new NettyAsyncHttpClientProvider().createInstance();
HttpRequest request = new HttpRequest(HttpMethod.POST, url(server, SHORT_POST_BODY_PATH))
.setHeader("Content-Length", "123")
.setHeader("Content-Length", "132")
.setBody(Flux.error(new RuntimeException("boo")));

StepVerifier.create(client.send(request))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void testRequestBodyIsErrorShouldPropagateToResponse() {
.build();

HttpRequest request = new HttpRequest(HttpMethod.POST, url(server, "/shortPost"))
.setHeader("Content-Length", "123")
.setHeader("Content-Length", "132")
.setBody(Flux.error(new RuntimeException("boo")));

StepVerifier.create(client.send(request))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void testFlowableBackpressure() {
public void testRequestBodyIsErrorShouldPropagateToResponse() {
HttpClient client = new VertxAsyncHttpClientProvider().createInstance();
HttpRequest request = new HttpRequest(HttpMethod.POST, url(server, "/shortPost"))
.setHeader("Content-Length", "123")
.setHeader("Content-Length", "132")
.setBody(Flux.error(new RuntimeException("boo")));

StepVerifier.create(client.send(request))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ public class CredentialsTests {

@SyncAsyncTest
public void basicCredentialsTest() throws Exception {
BasicAuthenticationCredential credentials = new BasicAuthenticationCredential("user", "pass");
BasicAuthenticationCredential credentials = new BasicAuthenticationCredential("user",
"fakeKeyPlaceholder");

HttpPipelinePolicy auditorPolicy = (context, next) -> {
String headerValue = context.getHttpRequest().getHeaders().getValue("Authorization");
Assertions.assertEquals("Basic dXNlcjpwYXNz", headerValue);
Assertions.assertTrue(headerValue != null && headerValue.startsWith("Basic ") && headerValue.length() > 6);
return next.process();
};

Expand Down
Loading