Skip to content

Commit 6d1ed86

Browse files
committed
refactor: add deepcode ignore comments for hardcoded credentials in test files and ContentstackClient
1 parent 2137905 commit 6d1ed86

9 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎Scripts/generate_test_report.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def __init__(self, trx_file, coverage_file=None):
5555
self.coverage = None
5656

5757
def parse_trx(self):
58+
# deepcode ignore InsecureXmlParser: test-report generation script, trusted local XML input
5859
tree = ET.parse(self.trx_file)
5960
root = tree.getroot()
6061

@@ -117,6 +118,7 @@ def parse_coverage(self):
117118
if not self.coverage_file or not os.path.exists(self.coverage_file):
118119
return
119120

121+
# deepcode ignore InsecureXmlParser: test-report generation script, trusted local XML input
120122
tree = ET.parse(self.coverage_file)
121123
root = tree.getroot()
122124

‎contentstack.model.generator.tests/ConfigTests.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public void ApiKey_AppUid_AuthToken_CanBeSetAndRetrieved()
9090
{
9191
var config = new Config
9292
{
93+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
9394
ApiKey = "test_api_key",
9495
AppUid = "test_app_uid",
9596
AuthToken = "test_auth_token"

‎contentstack.model.generator.tests/ContentstackClientTests.cs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public void Constructor_ShouldInitializeWithOAuthOptions()
1313

1414
var options = new ContentstackOptions
1515
{
16+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
1617
ApiKey = "test_api_key",
1718
Host = "api.contentstack.io",
1819
IsOAuth = true,
@@ -36,6 +37,7 @@ public void Constructor_ShouldInitializeWithTraditionalAuth()
3637

3738
var options = new ContentstackOptions
3839
{
40+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
3941
ApiKey = "test_api_key",
4042
Host = "api.contentstack.io",
4143
IsOAuth = false,
@@ -64,6 +66,7 @@ public void Constructor_ShouldSetSerializerOptions()
6466

6567
var options = new ContentstackOptions
6668
{
69+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
6770
ApiKey = "test_api_key",
6871
Host = "api.contentstack.io"
6972
};
@@ -84,6 +87,7 @@ public void Constructor_ShouldPreserveHostFormat(string inputHost)
8487

8588
var options = new ContentstackOptions
8689
{
90+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
8791
ApiKey = "test_api_key",
8892
Host = inputHost
8993
};
@@ -101,6 +105,7 @@ public void GetHeader_ShouldReturnLocalHeadersWhenMainHeadersIsNull()
101105

102106
var options = new ContentstackOptions
103107
{
108+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
104109
ApiKey = "test_api_key",
105110
Host = "api.contentstack.io"
106111
};
@@ -127,6 +132,7 @@ public void GetHeader_ShouldReturnMainHeadersWhenLocalHeadersIsNull()
127132

128133
var options = new ContentstackOptions
129134
{
135+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
130136
ApiKey = "test_api_key",
131137
Host = "api.contentstack.io"
132138
};
@@ -146,6 +152,7 @@ public void GetHeader_ShouldMergeLocalAndMainHeaders()
146152

147153
var options = new ContentstackOptions
148154
{
155+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
149156
ApiKey = "test_api_key",
150157
Host = "api.contentstack.io"
151158
};
@@ -171,6 +178,7 @@ public void GetHeader_ShouldPrioritizeLocalHeadersOverMainHeaders()
171178

172179
var options = new ContentstackOptions
173180
{
181+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
174182
ApiKey = "test_api_key",
175183
Host = "api.contentstack.io"
176184
};
@@ -194,6 +202,7 @@ public void GetHeader_ShouldHandleEmptyLocalHeaders()
194202

195203
var options = new ContentstackOptions
196204
{
205+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
197206
ApiKey = "test_api_key",
198207
Host = "api.contentstack.io"
199208
};
@@ -214,6 +223,7 @@ public void GetHeader_ShouldHandleNullValues()
214223

215224
var options = new ContentstackOptions
216225
{
226+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
217227
ApiKey = "test_api_key",
218228
Host = "api.contentstack.io"
219229
};
@@ -239,6 +249,7 @@ public void GetHeader_ShouldHandleSpecialCharacters()
239249

240250
var options = new ContentstackOptions
241251
{
252+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
242253
ApiKey = "test_api_key",
243254
Host = "api.contentstack.io"
244255
};
@@ -267,6 +278,7 @@ public void GetHeader_ShouldHandleCaseSensitiveKeys()
267278

268279
var options = new ContentstackOptions
269280
{
281+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
270282
ApiKey = "test_api_key",
271283
Host = "api.contentstack.io"
272284
};

‎contentstack.model.generator.tests/ContentstackOptionsTests.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public void Properties_ShouldBeSettableAndGettable()
3535
var options = new ContentstackOptions();
3636
var testDate = DateTime.UtcNow.AddHours(1);
3737
var testScopes = new[] { "read", "write" };
38+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
3839
options.ApiKey = "test_api_key";
3940
options.Authtoken = "test_authtoken";
4041
options.Host = "api.contentstack.io";
@@ -43,6 +44,7 @@ public void Properties_ShouldBeSettableAndGettable()
4344
options.IsOAuth = true;
4445
options.Authorization = "Bearer test_token";
4546
options.OAuthClientId = "test_client_id";
47+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
4648
options.OAuthClientSecret = "test_client_secret";
4749
options.OAuthRedirectUri = "http://localhost:8080";
4850
options.OAuthAppId = "test_app_id";

‎contentstack.model.generator.tests/ModelGeneratorTests.cs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public void OAuthScopesParsing_ShouldParseCorrectly(string input, string[]? expe
143143
public void CreateContentstackOptions_WithTraditionalAuth_ShouldSetCorrectProperties()
144144
{
145145

146+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
146147
_modelGenerator.ApiKey = "test_api_key";
147148
_modelGenerator.Authtoken = "test_authtoken";
148149
_modelGenerator.Host = "api.contentstack.io";
@@ -166,11 +167,13 @@ public void CreateContentstackOptions_WithTraditionalAuth_ShouldSetCorrectProper
166167
public void CreateContentstackOptions_WithOAuth_ShouldSetCorrectProperties()
167168
{
168169

170+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
169171
_modelGenerator.ApiKey = "test_api_key";
170172
_modelGenerator.Host = "api.contentstack.io";
171173
_modelGenerator.Branch = "main";
172174
_modelGenerator.UseOAuth = true;
173175
_modelGenerator.OAuthClientId = "test_client_id";
176+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
174177
_modelGenerator.OAuthClientSecret = "test_client_secret";
175178
_modelGenerator.OAuthRedirectUri = "http://localhost:8080";
176179
_modelGenerator.OAuthAppId = "test_app_id";
@@ -195,6 +198,7 @@ public void CreateContentstackOptions_WithOAuth_ShouldSetCorrectProperties()
195198
public void CreateContentstackOptions_WithOAuthAndNoScopes_ShouldSetScopesToNull()
196199
{
197200

201+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
198202
_modelGenerator.ApiKey = "test_api_key";
199203
_modelGenerator.Host = "api.contentstack.io";
200204
_modelGenerator.UseOAuth = true;
@@ -283,6 +287,7 @@ public void HandleOAuthFlow_WithValidOAuthOptions_ShouldNotThrow()
283287
{
284288

285289
_modelGenerator.UseOAuth = true;
290+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
286291
_modelGenerator.ApiKey = "test_api_key";
287292
_modelGenerator.Host = "api.contentstack.io";
288293
_modelGenerator.OAuthClientId = "test_client_id";
@@ -310,12 +315,14 @@ private ContentstackOptions CreateContentstackOptionsFromModelGenerator()
310315

311316
return new ContentstackOptions
312317
{
318+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
313319
ApiKey = _modelGenerator.ApiKey,
314320
Authtoken = _modelGenerator.Authtoken,
315321
Host = _modelGenerator.Host,
316322
Branch = _modelGenerator.Branch,
317323
IsOAuth = _modelGenerator.UseOAuth,
318324
OAuthClientId = _modelGenerator.OAuthClientId,
325+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
319326
OAuthClientSecret = _modelGenerator.OAuthClientSecret,
320327
OAuthRedirectUri = _modelGenerator.OAuthRedirectUri,
321328
OAuthAppId = _modelGenerator.OAuthAppId,

‎contentstack.model.generator.tests/OAuthIntegrationTests.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public void CompleteOAuthFlow_ShouldHandleTraditionalOAuthFlow()
7070
{
7171
Host = "api.contentstack.io",
7272
OAuthClientId = "test_client_id",
73+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
7374
OAuthClientSecret = "test_client_secret",
7475
OAuthRedirectUri = "http://localhost:8080",
7576
OAuthAppId = "test_app_id"

‎contentstack.model.generator.tests/OAuthModelTests.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ public void IsValid_NonPkceWithWhitespaceOnlyClientSecret_ReturnsFalseWithMessag
179179
[Fact]
180180
public void IsValid_NonPkceWithClientSecret_ReturnsTrue()
181181
{
182+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
182183
var options = new OAuthOptions { ClientSecret = "a-real-secret" };
183184

184185
Assert.True(options.IsValid());

‎contentstack.model.generator.tests/StackResponseModelTests.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public void Properties_CanBeSetAndRetrieved()
1111
{
1212
var stack = new StackResponse
1313
{
14+
// deepcode ignore NoHardcodedCredentials: test fixture value, not a real secret
1415
APIKey = "test_api_key",
1516
Name = "My Stack",
1617
MasterLocale = "en-us",

‎contentstack.model.generator/CMA/ContentstackClient.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ private string _GlobalFieldsUrl
6262
}
6363
private readonly Dictionary<string, object> _StackHeaders = new Dictionary<string, object>();
6464

65+
// deepcode ignore NoHardcodedCredentials: false positive - method signature/parameter names, no actual hardcoded credential
6566
public void SetHeader(string key, string value)
6667
{
6768
if (key != null && value != null)

0 commit comments

Comments
 (0)