Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ public class Sanitizer {
* 1 = SitePathStrict (enables strict site path analysis)
* 2 = SitePathLoose (enables loose site path analysis)
* Multiple flags can be combined with bitwise OR (e.g., 1 | 2 = 3)
* @param sendConcernLimit Maximum number of concerns to send.
* @param insertWarningAtProblemLocation Insert warnings at problem location (true) or prepend (false).
* @return true if initialization was successful, false otherwise.
*/
private static native boolean nativeInitialize(long loggerNativePtr,
private static native boolean nativeInitialize(long loggerNativePtr,
String notificationEventName,
boolean enforceSanitization,
String[] urlDomains,
String[] emailDomains,
boolean enforceSanitization,
String[] urlDomains,
String[] emailDomains,
int analyzerOptions,
int sendConcernLimit);
int sendConcernLimit,
boolean insertWarningAtProblemLocation);
/**
* Initializes the sanitizer with the provided configuration.
*
Expand Down Expand Up @@ -60,13 +63,14 @@ public static boolean initialize(SanitizerConfiguration config, String[] urlDoma
}

return nativeInitialize(
config.getLogger().getNativeILoggerPtr(),
config.getLogger().getNativeILoggerPtr(),
config.getNotificationEventName(),
config.isEnforceSanitization(),
urlDomains,
emailDomains,
analyzerOptions,
sendConcernLimit);
sendConcernLimit,
config.isInsertWarningAtProblemLocation());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public class SanitizerConfiguration {
*/
private boolean enforceSanitization = true;

/**
* Flag to control where warning messages are inserted.
* When true, warnings are inserted at the problem location.
* When false (default), warnings are prepended to the beginning.
* Optional. Defaults to false.
*/
private boolean insertWarningAtProblemLocation = false;

/**
* Constructs a new SanitizerConfiguration with the specified logger.
*
Expand Down Expand Up @@ -71,4 +79,22 @@ public boolean isEnforceSanitization() {
public void setEnforceSanitization(boolean enforceSanitization) {
this.enforceSanitization = enforceSanitization;
}

/**
* Returns whether warnings are inserted at the problem location.
*
* @return true if warnings are inserted at problem location, false if prepended
*/
public boolean isInsertWarningAtProblemLocation() {
return insertWarningAtProblemLocation;
}

/**
* Sets whether warnings should be inserted at the problem location.
*
* @param insertAtLocation true to insert at problem location, false to prepend
*/
public void setInsertWarningAtProblemLocation(boolean insertAtLocation) {
this.insertWarningAtProblemLocation = insertAtLocation;
}
}
6 changes: 3 additions & 3 deletions lib/include/public/Version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#define MAT_VERSION_HPP
// WARNING: DO NOT MODIFY THIS FILE!
// This file has been automatically generated, manual changes will be lost.
#define BUILD_VERSION_STR "3.10.20.1"
#define BUILD_VERSION 3,10,20,1
#define BUILD_VERSION_STR "3.10.23.1"
#define BUILD_VERSION 3,10,23,1

#ifndef RESOURCE_COMPILER_INVOKED
#include "ctmacros.hpp"
Expand All @@ -18,7 +18,7 @@ namespace MAT_NS_BEGIN {
uint64_t const Version =
((uint64_t)3 << 48) |
((uint64_t)10 << 32) |
((uint64_t)20 << 16) |
((uint64_t)23 << 16) |
((uint64_t)1);

} MAT_NS_END
Expand Down
5 changes: 4 additions & 1 deletion lib/jni/Sanitizer_jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Java_com_microsoft_applications_events_Sanitizer_isInitialized(const JNIEnv *env
* 2 = SitePathLoose (enables loose site path analysis)
* Multiple flags can be combined with bitwise OR (e.g., 1 | 2 = 3)
* @param sendConcernLimit Maximum number of concerns to send. 0 = no concerns sent, 65536+ = all concerns sent.
* @param insertWarningAtProblemLocation Insert warnings at problem location (true) or prepend (false).
* **/
extern "C"
JNIEXPORT jboolean JNICALL
Expand All @@ -48,7 +49,8 @@ Java_com_microsoft_applications_events_Sanitizer_isInitialized(const JNIEnv *env
jobjectArray urlDomains,
jobjectArray emailDomains,
jint analyzerOptions,
jint sendConcernLimit // number of concerns to upload. Set to 0 to upload none, greater than 65536 uploads everything.
jint sendConcernLimit, // number of concerns to upload. Set to 0 to upload none, greater than 65536 uploads everything.
jboolean insertWarningAtProblemLocation
) {

if (spSanitizer != nullptr) {
Expand Down Expand Up @@ -89,6 +91,7 @@ Java_com_microsoft_applications_events_Sanitizer_isInitialized(const JNIEnv *env
}

sanitizerConfig.SetAllWarningsToSanitizations = static_cast<bool>(warningsToSanitization);
sanitizerConfig.InsertWarningAtProblemLocation = static_cast<bool>(insertWarningAtProblemLocation);

spSanitizer = std::make_shared<Sanitizer>(sanitizerConfig);
return true;
Expand Down
2 changes: 1 addition & 1 deletion lib/modules
2 changes: 2 additions & 0 deletions wrappers/obj-c/ODWSanitizer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ +(void)initializeSanitizer:(ILogger *)logger withODWSanitizerInitConfig:(ODWSani
}
config.SetAllWarningsToSanitizations = initConfigObject.setWarningsToSanitization;
config.SendConcernLimit = static_cast<size_t>(initConfigObject.sendConcernLimit);
config.InsertWarningAtProblemLocation = initConfigObject.insertWarningAtProblemLocation;

_sanitizerPtr = std::make_shared<Sanitizer>(config);
LogManager::GetInstance()->SetDataInspector(_sanitizerPtr);
Expand Down Expand Up @@ -73,6 +74,7 @@ +(void)initializeSanitizer:(ILogger *)logger withODWSanitizerInitConfig:(ODWSani
}
config.SetAllWarningsToSanitizations = initConfigObject.setWarningsToSanitization;
config.SendConcernLimit = static_cast<size_t>(initConfigObject.sendConcernLimit);
config.InsertWarningAtProblemLocation = initConfigObject.insertWarningAtProblemLocation;

_sanitizerPtr = std::make_shared<Sanitizer>(config);
LogManager::GetInstance()->SetDataInspector(_sanitizerPtr);
Expand Down
7 changes: 7 additions & 0 deletions wrappers/obj-c/ODWSanitizerInitConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property(readwrite, nonatomic) NSUInteger sendConcernLimit;

/*!
@brief (OPTIONAL) When YES, warning messages are inserted at the problem location.
When NO (default), warnings are prepended to the beginning of the string.
Default value is `NO`.
*/
@property(readwrite, nonatomic) BOOL insertWarningAtProblemLocation;

// Initializer
- (instancetype)init;

Expand Down
1 change: 1 addition & 0 deletions wrappers/obj-c/ODWSanitizerInitConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ - (instancetype)init {
_notificationEventName = @"SanitizerConcerns"; // Default event name
_setWarningsToSanitization = YES; // Default to true
_sendConcernLimit = 65536; // Default to 65536 (upload all concerns)
_insertWarningAtProblemLocation = NO; // Default to NO (prepend warnings)
}
return self;
}
Expand Down
14 changes: 13 additions & 1 deletion wrappers/swift/Sources/OneDSSwift/SanitizerInitConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,19 @@ public final class SanitizerInitConfig {
odwSanitizerInitConfig.setWarningsToSanitization = newValue
}
}


/// (OPTIONAL) When true, warnings are inserted at the problem location.
/// When false (default), warnings are prepended to the beginning of the string.
/// Default value is `false`.
public var insertWarningAtProblemLocation: Bool {
get {
odwSanitizerInitConfig.insertWarningAtProblemLocation
}
set {
odwSanitizerInitConfig.insertWarningAtProblemLocation = newValue
}
}

/**
Returns the Obj-C object of the wrapper.

Expand Down
Loading