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

box / box-java-sdk / #7065

15 May 2026 10:50AM UTC coverage: 34.935% (-0.07%) from 35.007%
#7065

push

github

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

8 of 40 new or added lines in 5 files covered. (20.0%)

81 existing lines in 12 files now uncovered.

19331 of 55334 relevant lines covered (34.94%)

0.35 hits per line

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

57.14
/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() {
1✔
19
    this.keysToSanitize =
1✔
20
        mapOf(
1✔
21
            entryOf("authorization", ""),
1✔
22
            entryOf("access_token", ""),
1✔
23
            entryOf("refresh_token", ""),
1✔
24
            entryOf("subject_token", ""),
1✔
25
            entryOf("token", ""),
1✔
26
            entryOf("client_id", ""),
1✔
27
            entryOf("client_secret", ""),
1✔
28
            entryOf("shared_link", ""),
1✔
29
            entryOf("download_url", ""),
1✔
30
            entryOf("jwt_private_key", ""),
1✔
31
            entryOf("jwt_private_key_passphrase", ""),
1✔
32
            entryOf("password", ""));
1✔
33
  }
1✔
34

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

39
  public JsonNode sanitizeBody(JsonNode body) {
UNCOV
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