• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-java-sdk / #7023

15 May 2026 10:51AM UTC coverage: 12.506% (-0.01%) from 12.52%
#7023

push

github

web-flow
feat(boxsdkgen): Sanitize request body in `BoxAPIError` (box/box-codegen#948) (#1845)

0 of 41 new or added lines in 5 files covered. (0.0%)

20 existing lines in 10 files now uncovered.

8368 of 66914 relevant lines covered (12.51%)

0.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/box/sdkgen/internal/logging/DataSanitizer.java
1
package com.box.sdkgen.internal.logging;
2

3
import static com.box.sdkgen.internal.utils.UtilsManager.entryOf;
4
import static com.box.sdkgen.internal.utils.UtilsManager.mapOf;
5
import static com.box.sdkgen.internal.utils.UtilsManager.sanitizeMap;
6
import static com.box.sdkgen.serialization.json.JsonManager.jsonToSerializedData;
7
import static com.box.sdkgen.serialization.json.JsonManager.sanitizeFormEncodedBodyFromString;
8
import static com.box.sdkgen.serialization.json.JsonManager.sanitizeSerializedData;
9
import static com.box.sdkgen.serialization.json.JsonManager.sdToJson;
10

11
import com.fasterxml.jackson.databind.JsonNode;
12
import java.util.Map;
13

14
public class DataSanitizer {
15

16
  public final Map<String, String> keysToSanitize;
17

18
  public DataSanitizer() {
×
19
    this.keysToSanitize =
×
20
        mapOf(
×
21
            entryOf("authorization", ""),
×
22
            entryOf("access_token", ""),
×
23
            entryOf("refresh_token", ""),
×
24
            entryOf("subject_token", ""),
×
25
            entryOf("token", ""),
×
26
            entryOf("client_id", ""),
×
27
            entryOf("client_secret", ""),
×
28
            entryOf("shared_link", ""),
×
29
            entryOf("download_url", ""),
×
30
            entryOf("jwt_private_key", ""),
×
31
            entryOf("jwt_private_key_passphrase", ""),
×
32
            entryOf("password", ""));
×
33
  }
×
34

35
  public Map<String, String> sanitizeHeaders(Map<String, String> headers) {
36
    return sanitizeMap(headers, this.keysToSanitize);
×
37
  }
38

39
  public JsonNode sanitizeBody(JsonNode body) {
40
    return sanitizeSerializedData(body, this.keysToSanitize);
×
41
  }
42

43
  public String sanitizeFormEncodedBody(String body) {
NEW
44
    return sanitizeFormEncodedBodyFromString(body, this.keysToSanitize);
×
45
  }
46

47
  public String sanitizeStringBody(String body) {
NEW
48
    return sanitizeStringBody(body, null);
×
49
  }
50

51
  public String sanitizeStringBody(String body, String contentType) {
NEW
52
    if (contentType.equals("application/json")
×
NEW
53
        || contentType.equals("application/json-patch+json")) {
×
54
      try {
NEW
55
        return sdToJson(this.sanitizeBody(jsonToSerializedData(body)));
×
NEW
56
      } catch (Exception exception) {
×
NEW
57
        return body;
×
58
      }
59
    }
NEW
60
    if (contentType.equals("application/x-www-form-urlencoded")) {
×
NEW
61
      return this.sanitizeFormEncodedBody(body);
×
62
    }
NEW
63
    return body;
×
64
  }
65
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc