mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
serialization: obfuscate the serialized search paths
We noticed some Swift clients rely on the serialized search paths in the module to find dependencies and droping these paths altogether can lead to build failures like rdar://85840921. This change teaches the serialization to obfuscate the search paths and the deserialization to recover them. This allows clients to keep accessing these paths without exposing them when shipping the module to other users.
This commit is contained in:
@@ -1077,9 +1077,11 @@ void Serializer::writeHeader(const SerializationOptions &options) {
|
||||
options_block::XCCLayout XCC(Out);
|
||||
|
||||
const auto &PathRemapper = options.DebuggingOptionsPrefixMap;
|
||||
const auto &PathObfuscator = options.PathObfuscator;
|
||||
auto sdkPath = M->getASTContext().SearchPathOpts.SDKPath;
|
||||
SDKPath.emit(
|
||||
ScratchRecord,
|
||||
PathRemapper.remapPath(M->getASTContext().SearchPathOpts.SDKPath));
|
||||
PathObfuscator.obfuscate(PathRemapper.remapPath(sdkPath)));
|
||||
auto &Opts = options.ExtraClangOptions;
|
||||
for (auto Arg = Opts.begin(), E = Opts.end(); Arg != E; ++Arg) {
|
||||
StringRef arg(*Arg);
|
||||
@@ -1157,16 +1159,17 @@ void Serializer::writeInputBlock(const SerializationOptions &options) {
|
||||
input_block::ModuleInterfaceLayout ModuleInterface(Out);
|
||||
|
||||
if (options.SerializeOptionsForDebugging) {
|
||||
const auto &PathObfuscator = options.PathObfuscator;
|
||||
const auto &PathMapper = options.DebuggingOptionsPrefixMap;
|
||||
const SearchPathOptions &searchPathOpts = M->getASTContext().SearchPathOpts;
|
||||
// Put the framework search paths first so that they'll be preferred upon
|
||||
// deserialization.
|
||||
for (auto &framepath : searchPathOpts.FrameworkSearchPaths)
|
||||
SearchPath.emit(ScratchRecord, /*framework=*/true, framepath.IsSystem,
|
||||
PathMapper.remapPath(framepath.Path));
|
||||
PathObfuscator.obfuscate(PathMapper.remapPath(framepath.Path)));
|
||||
for (auto &path : searchPathOpts.ImportSearchPaths)
|
||||
SearchPath.emit(ScratchRecord, /*framework=*/false, /*system=*/false,
|
||||
PathMapper.remapPath(path));
|
||||
PathObfuscator.obfuscate(PathMapper.remapPath(path)));
|
||||
}
|
||||
|
||||
// Note: We're not using StringMap here because we don't need to own the
|
||||
|
||||
Reference in New Issue
Block a user