Changeset 223889 in webkit


Ignore:
Timestamp:
Oct 24, 2017 9:21:36 AM (6 years ago)
Author:
Brent Fulgham
Message:

Adopt new secure coding APIs
https://bugs.webkit.org/show_bug.cgi?id=178484
<rdar://problem/34837193>

Reviewed by Tim Horton.

Source/WebCore:

Switch to new NSKeyed[Un]Archiver methods that active and use
NSSecureCoding by default.

Most of the new API is wrapped in a set of convenience methods so we can
build without the new API on older systems.

No change in behavior.

  • editing/cocoa/EditorCocoa.mm:

(WebCore::archivedDataForAttributedString): Use new convenience method
to archive the string object.

  • loader/archive/cf/LegacyWebArchiveMac.mm:

(WebCore::LegacyWebArchive::createResourceResponseFromMacArchivedData): Update to
use secure coding where possible.
(WebCore::LegacyWebArchive::createPropertyListRepresentation): Ditto.

  • platform/ios/PlatformPasteboardIOS.mm:

(WebCore::PlatformPasteboard::write): Use new secure API.
(WebCore::PlatformPasteboard::typesSafeForDOMToReadAndWrite const): Ditto.

  • testing/cocoa/WebArchiveDumpSupport.mm:

(WebCoreTestSupport::createCFURLResponseFromResponseData): Update to
secure coding API where possible.

Source/WebCore/PAL:

Add new convenience methods (and SPI headers) so we can adopt new NSKeyedArchiver
API that uses secure coding by default.

  • PAL.xcodeproj/project.pbxproj:
  • pal/spi/cocoa/NSKeyedArchiverSPI.h: Added.

(securelyArchivedDataWithRootObject): New convenience method.
(securelyUnarchiveRootObjectOfClassFromData): Ditto.
(secureArchiverFromMutableData): Ditto.
(secureUnarchiverFromData): Ditto.

Source/WebKit:

Switch to new NSKeyed[Un]Archiver methods that active and use
NSSecureCoding by default.

  • Platform/ios/AccessibilityIOS.mm:

(WebKit::newAccessibilityRemoteToken): Use secure-by-default API.

  • Shared/Cocoa/DataDetectionResult.mm:

(WebKit::DataDetectionResult::encode const): Ditto.
(WebKit::DataDetectionResult::decode): Ditto.

  • Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:

(IPC::ArgumentCoder<WebCore::Payment>::encode): Ditto.
(IPC::ArgumentCoder<WebCore::Payment>::decode): Ditto.
(IPC::ArgumentCoder<WebCore::PaymentContact>::encode): Ditto.
(IPC::ArgumentCoder<WebCore::PaymentContact>::decode): Ditto.
(IPC::ArgumentCoder<WebCore::PaymentMerchantSession>::encode): Ditto.
(IPC::ArgumentCoder<WebCore::PaymentMerchantSession>::decode): Ditto.
(IPC::ArgumentCoder<WebCore::PaymentMethod>::encode): Ditto.
(IPC::ArgumentCoder<WebCore::PaymentMethod>::decode): Ditto.

  • Shared/ios/InteractionInformationAtPosition.mm:

(WebKit::InteractionInformationAtPosition::encode const): Ditto.
(WebKit::InteractionInformationAtPosition::decode): Ditto.

  • Shared/mac/WebCoreArgumentCodersMac.mm:

(IPC::ArgumentCoder<ProtectionSpace>::encodePlatformData): Ditto.
(IPC::ArgumentCoder<ProtectionSpace>::decodePlatformData): Ditto.
(IPC::ArgumentCoder<Credential>::encodePlatformData): Ditto.
(IPC::ArgumentCoder<Credential>::decodePlatformData): Ditto.
(IPC::ArgumentCoder<ContentFilterUnblockHandler>::encode): Ditto.
(IPC::ArgumentCoder<ContentFilterUnblockHandler>::decode): Ditto.
(IPC::ArgumentCoder<MediaPlaybackTargetContext>::encodePlatformData): Ditto.
(IPC::ArgumentCoder<MediaPlaybackTargetContext>::decodePlatformData): Ditto.

  • Shared/mac/WebHitTestResultData.mm:

(WebKit::WebHitTestResultData::platformEncode const): Ditto.
(WebKit::WebHitTestResultData::platformDecode): Ditto.

  • UIProcess/API/Cocoa/WKProcessPool.mm:

(-[WKProcessPool _setObject:forBundleParameter:]): Ditto.
(-[WKProcessPool _setObjectsForBundleParametersWithDictionary:]): Ditto.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _setInputDelegate:]): Ditto.

  • UIProcess/Cocoa/WebProcessPoolCocoa.mm:

(WebKit::WebProcessPool::platformInitializeWebProcess): Ditto.

  • UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::startAssistingNode): Ditto.

  • WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:

(-[WKWebProcessPlugInBrowserContextController _setFormDelegate:]): Ditto.

  • WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:

(WebKit::InjectedBundle::initialize): Ditto.
(WebKit::InjectedBundle::setBundleParameter): Ditto.
(WebKit::InjectedBundle::setBundleParameters): Ditto.

Location:
trunk/Source
Files:
1 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r223887 r223889  
     12017-10-24  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Adopt new secure coding APIs
     4        https://bugs.webkit.org/show_bug.cgi?id=178484
     5        <rdar://problem/34837193>
     6
     7        Reviewed by Tim Horton.
     8
     9        Switch to new NSKeyed[Un]Archiver methods that active and use
     10        NSSecureCoding by default.
     11
     12        Most of the new API is wrapped in a set of convenience methods so we can
     13        build without the new API on older systems.
     14
     15        No change in behavior.
     16
     17        * editing/cocoa/EditorCocoa.mm:
     18        (WebCore::archivedDataForAttributedString): Use new convenience method
     19        to archive the string object.
     20        * loader/archive/cf/LegacyWebArchiveMac.mm:
     21        (WebCore::LegacyWebArchive::createResourceResponseFromMacArchivedData): Update to
     22        use secure coding where possible.
     23        (WebCore::LegacyWebArchive::createPropertyListRepresentation): Ditto.
     24        * platform/ios/PlatformPasteboardIOS.mm:
     25        (WebCore::PlatformPasteboard::write): Use new secure API.
     26        (WebCore::PlatformPasteboard::typesSafeForDOMToReadAndWrite const): Ditto.
     27        * testing/cocoa/WebArchiveDumpSupport.mm:
     28        (WebCoreTestSupport::createCFURLResponseFromResponseData): Update to
     29        secure coding API where possible.
     30
    1312017-10-24  Miguel Gomez  <magomez@igalia.com>
    232
  • trunk/Source/WebCore/PAL/ChangeLog

    r223791 r223889  
     12017-10-24  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Adopt new secure coding APIs
     4        https://bugs.webkit.org/show_bug.cgi?id=178484
     5        <rdar://problem/34837193>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add new convenience methods (and SPI headers) so we can adopt new NSKeyedArchiver
     10        API that uses secure coding by default.
     11
     12        * PAL.xcodeproj/project.pbxproj:
     13        * pal/spi/cocoa/NSKeyedArchiverSPI.h: Added.
     14        (securelyArchivedDataWithRootObject): New convenience method.
     15        (securelyUnarchiveRootObjectOfClassFromData): Ditto.
     16        (secureArchiverFromMutableData): Ditto.
     17        (secureUnarchiverFromData): Ditto.
     18
    1192017-10-20  Alex Christensen  <achristensen@webkit.org>
    220
  • trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj

    r223206 r223889  
    109109                1C4876D91F8D7F4E00CCEEBD /* Logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4876D71F8D7F4E00CCEEBD /* Logging.h */; };
    110110                1C4876E01F8D837500CCEEBD /* LoggingCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C4876DF1F8D837500CCEEBD /* LoggingCocoa.mm */; };
     111                7A1656441F97B2B900BA3CE4 /* NSKeyedArchiverSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A1656431F97B2B800BA3CE4 /* NSKeyedArchiverSPI.h */; };
    111112                A10265871F56746100B4C844 /* FoundationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A10265861F56746100B4C844 /* FoundationSPI.h */; };
    112113                A10265891F56747A00B4C844 /* HIToolboxSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A10265881F56747A00B4C844 /* HIToolboxSPI.h */; };
     
    250251                1C67CEA11E32EDA800F80F2E /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = "<group>"; };
    251252                1C67CEA21E32EE2600F80F2E /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
     253                7A1656431F97B2B800BA3CE4 /* NSKeyedArchiverSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSKeyedArchiverSPI.h; sourceTree = "<group>"; };
    252254                A10265861F56746100B4C844 /* FoundationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FoundationSPI.h; sourceTree = "<group>"; };
    253255                A10265881F56747A00B4C844 /* HIToolboxSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HIToolboxSPI.h; sourceTree = "<group>"; };
     
    363365                                0C2DA1321F3BEB4900DBC317 /* NSExtensionSPI.h */,
    364366                                0C2DA1331F3BEB4900DBC317 /* NSFileManagerSPI.h */,
     367                                7A1656431F97B2B800BA3CE4 /* NSKeyedArchiverSPI.h */,
    365368                                0C2DA1341F3BEB4900DBC317 /* NSStringSPI.h */,
    366369                                0C2DA1351F3BEB4900DBC317 /* NSTouchBarSPI.h */,
     
    651654                                A10826FE1F58A433004772AC /* NSGraphicsSPI.h in Headers */,
    652655                                0C7785911F45130F00F4EBB6 /* NSImmediateActionGestureRecognizerSPI.h in Headers */,
     656                                7A1656441F97B2B900BA3CE4 /* NSKeyedArchiverSPI.h in Headers */,
    653657                                0C7785921F45130F00F4EBB6 /* NSMenuSPI.h in Headers */,
    654658                                0C7785931F45130F00F4EBB6 /* NSPasteboardSPI.h in Headers */,
  • trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm

    r223678 r223889  
    5353#import "markup.h"
    5454#import <pal/spi/cocoa/NSAttributedStringSPI.h>
     55#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    5556#import <wtf/BlockObjCExceptions.h>
    5657
     
    142143        return nullptr;
    143144
    144     return SharedBuffer::create([NSKeyedArchiver archivedDataWithRootObject:attributedString]);
     145    return SharedBuffer::create(securelyArchivedDataWithRootObject(attributedString));
    145146}
    146147
  • trunk/Source/WebCore/loader/archive/cf/LegacyWebArchiveMac.mm

    r222779 r223889  
    2727 */
    2828
    29 #include "config.h"
    30 #include "LegacyWebArchive.h"
     29#import "config.h"
     30#import "LegacyWebArchive.h"
     31
     32#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    3133
    3234namespace WebCore {
     
    4345   
    4446    NSURLResponse *response = nil;
    45     NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:(NSData *)responseData];
     47    auto unarchiver = secureUnarchiverFromData((NSData *)responseData);
     48    @try {
    4649#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || PLATFORM(IOS)
    47     // Because of <rdar://problem/34063313> we can't use this for decoding in older OS's.
    48     [unarchiver setRequiresSecureCoding:YES];
    49     @try {
    5050        response = [unarchiver decodeObjectOfClass:[NSURLResponse class] forKey:LegacyWebArchiveResourceResponseKey];
    5151#else
    52     @try {
     52        // Because of <rdar://problem/34063313> we can't use secure coding for decoding in older OS's.
     53        [unarchiver setRequiresSecureCoding:NO];
    5354        id responseObject = [unarchiver decodeObjectForKey:LegacyWebArchiveResourceResponseKey];
    5455        if ([responseObject isKindOfClass:[NSURLResponse class]])
     
    6061        response = nil;
    6162    }
    62     [unarchiver release];
    63    
     63
    6464    return ResourceResponse(response);
    6565}
     
    7474    CFMutableDataRef responseData = CFDataCreateMutable(0, 0);
    7575
    76     NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:(NSMutableData *)responseData];
     76    auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:(NSMutableData *)responseData]);
    7777#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || PLATFORM(IOS)
    7878    // Because of <rdar://problem/34063313> we can't use this for encoding in older OS's.
     
    8181    [archiver encodeObject:nsResponse forKey:LegacyWebArchiveResourceResponseKey];
    8282    [archiver finishEncoding];
    83     [archiver release];
    84    
     83
    8584    return adoptCF(responseData);
    8685}
  • trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm

    r223678 r223889  
    11/*
    2  * Copyright (C) 2013 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2013-2017 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3737#import <UIKit/UIImage.h>
    3838#import <UIKit/UIPasteboard.h>
     39#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    3940#import <pal/spi/ios/UIKitSPI.h>
    4041#import <wtf/ListHashSet.h>
     
    265266
    266267    if (content.dataInAttributedStringFormat) {
    267         NSAttributedString *attributedString = [NSKeyedUnarchiver unarchiveObjectWithData:content.dataInAttributedStringFormat->createNSData().get()];
     268        NSAttributedString *attributedString = securelyUnarchiveObjectOfClassFromData([NSAttributedString class], content.dataInAttributedStringFormat->createNSData().get());
    268269        if (attributedString)
    269270            [representationsToRegister addRepresentingObject:attributedString];
     
    380381            continue;
    381382
    382         id teamDataObject = [NSKeyedUnarchiver unarchiveObjectWithData:provider.teamData];
    383         if (!teamDataObject || ![teamDataObject isKindOfClass:[NSDictionary class]])
    384             continue;
    385 
    386         id originInTeamData = [(NSDictionary *)teamDataObject objectForKey:@(originKeyForTeamData)];
     383        NSDictionary *teamDataObject = securelyUnarchiveObjectOfClassFromData([NSDictionary class], provider.teamData);
     384        if (!teamDataObject)
     385            continue;
     386
     387        id originInTeamData = [teamDataObject objectForKey:@(originKeyForTeamData)];
    387388        if (![originInTeamData isKindOfClass:[NSString class]])
    388389            continue;
     
    445446            for (auto& type : data.orderedTypes)
    446447                [typesAsNSArray addObject:type];
    447             [representationsToRegister setTeamData:[NSKeyedArchiver archivedDataWithRootObject:@{
    448                 @(originKeyForTeamData) : data.origin, @(customTypesKeyForTeamData) : typesAsNSArray }]];
     448            [representationsToRegister setTeamData:securelyArchivedDataWithRootObject(@{ @(originKeyForTeamData) : data.origin, @(customTypesKeyForTeamData) : typesAsNSArray })];
    449449            [representationsToRegister addData:serializedSharedBuffer.get() forType:@(PasteboardCustomData::cocoaType())];
    450450        }
  • trunk/Source/WebCore/testing/cocoa/WebArchiveDumpSupport.mm

    r222786 r223889  
    3131#import <CFNetwork/CFNetwork.h>
    3232#import <pal/spi/cf/CFNetworkSPI.h>
     33#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    3334#import <wtf/NeverDestroyed.h>
    3435#import <wtf/RetainPtr.h>
     
    4142static CFURLResponseRef createCFURLResponseFromResponseData(CFDataRef responseData)
    4243{
    43     RetainPtr<NSKeyedUnarchiver> unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:(NSData *)responseData]);
    4444    NSURLResponse *response;
     45    auto unarchiver = secureUnarchiverFromData((NSData *)responseData);
     46    @try {
    4547#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || PLATFORM(IOS)
    46     // Because of <rdar://problem/34063313> we can't use this for decoding in older OS's.
    47     [unarchiver setRequiresSecureCoding:YES];
    48     @try {
    4948        response = [unarchiver decodeObjectOfClass:[NSURLResponse class] forKey:@"WebResourceResponse"]; // WebResourceResponseKey in WebResource.m
    5049#else
    51     @try {
     50        // Because of <rdar://problem/34063313> we can't use secure coding for decoding in older OS's.
     51        [unarchiver setRequiresSecureCoding:NO];
    5252        response = [unarchiver decodeObjectForKey:@"WebResourceResponse"]; // WebResourceResponseKey in WebResource.m
    5353#endif
  • trunk/Source/WebKit/ChangeLog

    r223884 r223889  
     12017-10-24  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Adopt new secure coding APIs
     4        https://bugs.webkit.org/show_bug.cgi?id=178484
     5        <rdar://problem/34837193>
     6
     7        Reviewed by Tim Horton.
     8
     9        Switch to new NSKeyed[Un]Archiver methods that active and use
     10        NSSecureCoding by default.
     11
     12        * Platform/ios/AccessibilityIOS.mm:
     13        (WebKit::newAccessibilityRemoteToken): Use secure-by-default API.
     14        * Shared/Cocoa/DataDetectionResult.mm:
     15        (WebKit::DataDetectionResult::encode const): Ditto.
     16        (WebKit::DataDetectionResult::decode): Ditto.
     17        * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
     18        (IPC::ArgumentCoder<WebCore::Payment>::encode): Ditto.
     19        (IPC::ArgumentCoder<WebCore::Payment>::decode): Ditto.
     20        (IPC::ArgumentCoder<WebCore::PaymentContact>::encode): Ditto.
     21        (IPC::ArgumentCoder<WebCore::PaymentContact>::decode): Ditto.
     22        (IPC::ArgumentCoder<WebCore::PaymentMerchantSession>::encode): Ditto.
     23        (IPC::ArgumentCoder<WebCore::PaymentMerchantSession>::decode): Ditto.
     24        (IPC::ArgumentCoder<WebCore::PaymentMethod>::encode): Ditto.
     25        (IPC::ArgumentCoder<WebCore::PaymentMethod>::decode): Ditto.
     26        * Shared/ios/InteractionInformationAtPosition.mm:
     27        (WebKit::InteractionInformationAtPosition::encode const): Ditto.
     28        (WebKit::InteractionInformationAtPosition::decode): Ditto.
     29        * Shared/mac/WebCoreArgumentCodersMac.mm:
     30        (IPC::ArgumentCoder<ProtectionSpace>::encodePlatformData): Ditto.
     31        (IPC::ArgumentCoder<ProtectionSpace>::decodePlatformData): Ditto.
     32        (IPC::ArgumentCoder<Credential>::encodePlatformData): Ditto.
     33        (IPC::ArgumentCoder<Credential>::decodePlatformData): Ditto.
     34        (IPC::ArgumentCoder<ContentFilterUnblockHandler>::encode): Ditto.
     35        (IPC::ArgumentCoder<ContentFilterUnblockHandler>::decode): Ditto.
     36        (IPC::ArgumentCoder<MediaPlaybackTargetContext>::encodePlatformData): Ditto.
     37        (IPC::ArgumentCoder<MediaPlaybackTargetContext>::decodePlatformData): Ditto.
     38        * Shared/mac/WebHitTestResultData.mm:
     39        (WebKit::WebHitTestResultData::platformEncode const): Ditto.
     40        (WebKit::WebHitTestResultData::platformDecode): Ditto.
     41        * UIProcess/API/Cocoa/WKProcessPool.mm:
     42        (-[WKProcessPool _setObject:forBundleParameter:]): Ditto.
     43        (-[WKProcessPool _setObjectsForBundleParametersWithDictionary:]): Ditto.
     44        * UIProcess/API/Cocoa/WKWebView.mm:
     45        (-[WKWebView _setInputDelegate:]): Ditto.
     46        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
     47        (WebKit::WebProcessPool::platformInitializeWebProcess): Ditto.
     48        * UIProcess/ios/PageClientImplIOS.mm:
     49        (WebKit::PageClientImpl::startAssistingNode): Ditto.
     50        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
     51        (-[WKWebProcessPlugInBrowserContextController _setFormDelegate:]): Ditto.
     52        * WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:
     53        (WebKit::InjectedBundle::initialize): Ditto.
     54        (WebKit::InjectedBundle::setBundleParameter): Ditto.
     55        (WebKit::InjectedBundle::setBundleParameters): Ditto.
     56
    1572017-10-24  Zan Dobersek  <zdobersek@igalia.com>
    258
  • trunk/Source/WebKit/Platform/ios/AccessibilityIOS.mm

    r191904 r223889  
    2626#import "config.h"
    2727#import "AccessibilityIOS.h"
     28#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    2829
    2930#if PLATFORM(IOS)
     
    3536    if (!uuid)
    3637        return nil;
    37     return [NSKeyedArchiver archivedDataWithRootObject:@{ @"ax-pid" : @(getpid()), @"ax-uuid" : [uuid UUIDString], @"ax-register" : @YES }];
     38    return securelyArchivedDataWithRootObject(@{ @"ax-pid" : @(getpid()), @"ax-uuid" : [uuid UUIDString], @"ax-register" : @YES });
    3839}
    3940
  • trunk/Source/WebKit/Shared/Cocoa/DataDetectionResult.mm

    r220506 r223889  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030#import "WebCoreArgumentCoders.h"
    3131#import <pal/spi/cocoa/DataDetectorsCoreSPI.h>
     32#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    3233#import <wtf/SoftLinking.h>
    3334
     
    4243{
    4344    RetainPtr<NSMutableData> data = adoptNS([[NSMutableData alloc] init]);
    44     RetainPtr<NSKeyedArchiver> archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    45     [archiver setRequiresSecureCoding:YES];
     45    auto archiver = secureArchiverFromMutableData(data.get());
    4646    [archiver encodeObject:results.get() forKey:@"dataDetectorResults"];
    4747    [archiver finishEncoding];
     
    5555    if (!IPC::decode(decoder, data))
    5656        return false;
    57    
    58     RetainPtr<NSKeyedUnarchiver> unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:(NSData *)data.get()]);
    59     [unarchiver setRequiresSecureCoding:YES];
     57
     58    auto unarchiver = secureUnarchiverFromData((NSData *)data.get());
    6059    @try {
    6160        result.results = [unarchiver decodeObjectOfClasses:[NSSet setWithArray:@[ [NSArray class], getDDScannerResultClass()] ] forKey:@"dataDetectorResults"];
  • trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm

    r222584 r223889  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3131#import "DataReference.h"
    3232#import <WebCore/PaymentAuthorizationStatus.h>
     33#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    3334#import <pal/spi/cocoa/PassKitSPI.h>
    3435#import <wtf/SoftLinking.h>
     
    5253{
    5354    auto data = adoptNS([[NSMutableData alloc] init]);
    54     auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    55 
    56     [archiver setRequiresSecureCoding:YES];
     55    auto archiver = secureArchiverFromMutableData(data.get());
    5756
    5857    [archiver encodeObject:payment.pkPayment() forKey:NSKeyedArchiveRootObjectKey];
     
    6968
    7069    auto data = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(dataReference.data())) length:dataReference.size() freeWhenDone:NO]);
    71     auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:data.get()]);
    72     [unarchiver setRequiresSecureCoding:YES];
     70    auto unarchiver = secureUnarchiverFromData(data.get());
    7371    @try {
    7472        PKPayment *pkPayment = [unarchiver decodeObjectOfClass:getPKPaymentClass() forKey:NSKeyedArchiveRootObjectKey];
     
    107105{
    108106    auto data = adoptNS([[NSMutableData alloc] init]);
    109     auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    110 
    111     [archiver setRequiresSecureCoding:YES];
     107    auto archiver = secureArchiverFromMutableData(data.get());
    112108
    113109    [archiver encodeObject:paymentContact.pkContact() forKey:NSKeyedArchiveRootObjectKey];
     
    124120
    125121    auto data = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(dataReference.data())) length:dataReference.size() freeWhenDone:NO]);
    126     auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:data.get()]);
    127     [unarchiver setRequiresSecureCoding:YES];
     122    auto unarchiver = secureUnarchiverFromData(data.get());
    128123    @try {
    129124        PKContact *pkContact = [unarchiver decodeObjectOfClass:getPKContactClass() forKey:NSKeyedArchiveRootObjectKey];
     
    168163{
    169164    auto data = adoptNS([[NSMutableData alloc] init]);
    170     auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    171 
    172     [archiver setRequiresSecureCoding:YES];
     165    auto archiver = secureArchiverFromMutableData(data.get());
    173166
    174167    [archiver encodeObject:paymentMerchantSession.pkPaymentMerchantSession() forKey:NSKeyedArchiveRootObjectKey];
     
    185178
    186179    auto data = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(dataReference.data())) length:dataReference.size() freeWhenDone:NO]);
    187     auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:data.get()]);
    188     [unarchiver setRequiresSecureCoding:YES];
     180    auto unarchiver = secureUnarchiverFromData(data.get());
    189181    @try {
    190182        PKPaymentMerchantSession *pkPaymentMerchantSession = [unarchiver decodeObjectOfClass:getPKPaymentMerchantSessionClass() forKey:NSKeyedArchiveRootObjectKey];
     
    196188
    197189    [unarchiver finishDecoding];
    198 
    199190    return true;
    200191}
     
    203194{
    204195    auto data = adoptNS([[NSMutableData alloc] init]);
    205     auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    206 
    207     [archiver setRequiresSecureCoding:YES];
     196    auto archiver = secureArchiverFromMutableData(data.get());
    208197
    209198    [archiver encodeObject:paymentMethod.pkPaymentMethod() forKey:NSKeyedArchiveRootObjectKey];
     
    220209
    221210    auto data = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(dataReference.data())) length:dataReference.size() freeWhenDone:NO]);
    222     auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:data.get()]);
    223     [unarchiver setRequiresSecureCoding:YES];
     211    auto unarchiver = secureUnarchiverFromData(data.get());
    224212    @try {
    225213        PKPaymentMethod *pkPaymentMethod = [unarchiver decodeObjectOfClass:getPKPaymentMethodClass() forKey:NSKeyedArchiveRootObjectKey];
  • trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm

    r222584 r223889  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030#import "WebCoreArgumentCoders.h"
    3131#import <pal/spi/cocoa/DataDetectorsCoreSPI.h>
     32#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    3233#import <wtf/SoftLinking.h>
    3334
     
    7475        encoder << dataDetectorIdentifier;
    7576        RetainPtr<NSMutableData> data = adoptNS([[NSMutableData alloc] init]);
    76         RetainPtr<NSKeyedArchiver> archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    77         [archiver setRequiresSecureCoding:YES];
     77        auto archiver = secureArchiverFromMutableData(data.get());
    7878        [archiver encodeObject:dataDetectorResults.get() forKey:@"dataDetectorResults"];
    7979        [archiver finishEncoding];
     
    169169            return false;
    170170       
    171         RetainPtr<NSKeyedUnarchiver> unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:(NSData *)data.get()]);
    172         [unarchiver setRequiresSecureCoding:YES];
     171        auto unarchiver = secureUnarchiverFromData((NSData *)data.get());
    173172        @try {
    174173            result.dataDetectorResults = [unarchiver decodeObjectOfClasses:[NSSet setWithArray:@[ [NSArray class], getDDScannerResultClass()] ] forKey:@"dataDetectorResults"];
  • trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm

    r223408 r223889  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
    33 * Copyright (C) 2013 Company 100 Inc. All rights reserved.
    44 *
     
    3939#import <WebCore/ResourceRequest.h>
    4040#import <pal/spi/cf/CFNetworkSPI.h>
     41#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    4142
    4243#if USE(CFURLCONNECTION)
     
    473474void ArgumentCoder<ProtectionSpace>::encodePlatformData(Encoder& encoder, const ProtectionSpace& space)
    474475{
    475     RetainPtr<NSMutableData> data = adoptNS([[NSMutableData alloc] init]);
    476     RetainPtr<NSKeyedArchiver> archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    477     [archiver setRequiresSecureCoding:YES];
     476    auto data = adoptNS([[NSMutableData alloc] init]);
     477    auto archiver = secureArchiverFromMutableData(data.get());
    478478    [archiver encodeObject:space.nsSpace() forKey:@"protectionSpace"];
    479479    [archiver finishEncoding];
     
    487487        return false;
    488488
    489     RetainPtr<NSKeyedUnarchiver> unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:(NSData *)data.get()]);
    490     [unarchiver setRequiresSecureCoding:YES];
     489    auto unarchiver = secureUnarchiverFromData((NSData *)data.get());
    491490    @try {
    492491        if (RetainPtr<NSURLProtectionSpace> nsSpace = [unarchiver decodeObjectOfClass:[NSURLProtectionSpace class] forKey:@"protectionSpace"])
     
    520519
    521520    encoder << false;
    522     RetainPtr<NSMutableData> data = adoptNS([[NSMutableData alloc] init]);
    523     RetainPtr<NSKeyedArchiver> archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    524     [archiver setRequiresSecureCoding:YES];
     521    auto data = adoptNS([[NSMutableData alloc] init]);
     522    auto archiver = secureArchiverFromMutableData(data.get());
    525523    [archiver encodeObject:nsCredential forKey:@"credential"];
    526524    [archiver finishEncoding];
     
    561559        return false;
    562560
    563     RetainPtr<NSKeyedUnarchiver> unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:(NSData *)data.get()]);
    564     [unarchiver setRequiresSecureCoding:YES];
     561    auto unarchiver = secureUnarchiverFromData((NSData *)data.get());
    565562    @try {
    566563        if (RetainPtr<NSURLCredential> nsCredential = [unarchiver decodeObjectOfClass:[NSURLCredential class] forKey:@"credential"])
     
    623620void ArgumentCoder<ContentFilterUnblockHandler>::encode(Encoder& encoder, const ContentFilterUnblockHandler& contentFilterUnblockHandler)
    624621{
    625     RetainPtr<NSMutableData> data = adoptNS([[NSMutableData alloc] init]);
    626     RetainPtr<NSKeyedArchiver> archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    627     [archiver setRequiresSecureCoding:YES];
     622    auto data = adoptNS([[NSMutableData alloc] init]);
     623    auto archiver = secureArchiverFromMutableData(data.get());
    628624    contentFilterUnblockHandler.encode(archiver.get());
    629625    [archiver finishEncoding];
     
    637633        return false;
    638634
    639     RetainPtr<NSKeyedUnarchiver> unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:(NSData *)data.get()]);
    640     [unarchiver setRequiresSecureCoding:YES];
     635    auto unarchiver = secureUnarchiverFromData((NSData *)data.get());
    641636    if (!ContentFilterUnblockHandler::decode(unarchiver.get(), contentFilterUnblockHandler))
    642637        return false;
     
    657652void ArgumentCoder<MediaPlaybackTargetContext>::encodePlatformData(Encoder& encoder, const MediaPlaybackTargetContext& target)
    658653{
    659     RetainPtr<NSMutableData> data = adoptNS([[NSMutableData alloc] init]);
    660     RetainPtr<NSKeyedArchiver> archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    661     [archiver setRequiresSecureCoding:YES];
     654    auto data = adoptNS([[NSMutableData alloc] init]);
     655    auto archiver = secureArchiverFromMutableData(data.get());
    662656
    663657    if ([getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
     
    678672        return false;
    679673
    680     RetainPtr<NSKeyedUnarchiver> unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:(NSData *)data.get()]);
    681     [unarchiver setRequiresSecureCoding:YES];
     674    auto unarchiver = secureUnarchiverFromData((NSData *)data.get());
    682675
    683676    AVOutputContext *context = nil;
  • trunk/Source/WebKit/Shared/mac/WebHitTestResultData.mm

    r222584 r223889  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3434#import "WebCoreArgumentCoders.h"
    3535#import <WebCore/TextIndicator.h>
     36#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    3637#import <pal/spi/mac/DataDetectorsSPI.h>
    3738
     
    4546        return;
    4647
    47     RetainPtr<NSMutableData> data = adoptNS([[NSMutableData alloc] init]);
    48     RetainPtr<NSKeyedArchiver> archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    49     [archiver setRequiresSecureCoding:YES];
     48    auto data = adoptNS([[NSMutableData alloc] init]);
     49    auto archiver = secureArchiverFromMutableData(data.get());
    5050    [archiver encodeObject:detectedDataActionContext.get() forKey:@"actionContext"];
    5151    [archiver finishEncoding];
     
    7676        return false;
    7777
    78     RetainPtr<NSKeyedUnarchiver> unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:(NSData *)data.get()]);
    79     [unarchiver setRequiresSecureCoding:YES];
     78    auto unarchiver = secureUnarchiverFromData((NSData *)data.get());
    8079    @try {
    8180        hitTestResultData.detectedDataActionContext = [unarchiver decodeObjectOfClass:getDDActionContextClass() forKey:@"actionContext"];
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm

    r222613 r223889  
    4949#import <WebCore/PluginData.h>
    5050#import <pal/spi/cf/CFNetworkSPI.h>
     51#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    5152#import <wtf/RetainPtr.h>
    5253
     
    214215
    215216    auto data = adoptNS([[NSMutableData alloc] init]);
    216     auto keyedArchiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    217     [keyedArchiver setRequiresSecureCoding:YES];
     217    auto keyedArchiver = secureArchiverFromMutableData(data.get());
    218218
    219219    @try {
     
    237237
    238238    auto data = adoptNS([[NSMutableData alloc] init]);
    239     auto keyedArchiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    240     [keyedArchiver setRequiresSecureCoding:YES];
     239    auto keyedArchiver = secureArchiverFromMutableData(data.get());
    241240
    242241    @try {
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r223726 r223889  
    103103#import <WebCore/ViewportArguments.h>
    104104#import <WebCore/WritingMode.h>
     105#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    105106#import <pal/spi/mac/NSTextFinderSPI.h>
    106107#import <wtf/BlockPtr.h>
     
    45264527            if (API::Data* data = static_cast<API::Data*>(userData)) {
    45274528                auto nsData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(data->bytes())) length:data->size() freeWhenDone:NO]);
    4528                 auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:nsData.get()]);
    4529                 [unarchiver setRequiresSecureCoding:YES];
     4529                auto unarchiver = secureUnarchiverFromData(nsData.get());
    45304530                @try {
    45314531                    userObject = [unarchiver decodeObjectOfClass:[NSObject class] forKey:@"userObject"];
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r223207 r223889  
    5050#import <WebCore/SharedBuffer.h>
    5151#import <pal/spi/cf/CFNetworkSPI.h>
     52#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    5253#import <sys/param.h>
    5354
     
    216217    if (m_bundleParameters) {
    217218        auto data = adoptNS([[NSMutableData alloc] init]);
    218         auto keyedArchiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    219 
    220         [keyedArchiver setRequiresSecureCoding:YES];
     219        auto keyedArchiver = secureArchiverFromMutableData(data.get());
    221220
    222221        @try {
  • trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm

    r221873 r223889  
    5656#import <WebCore/TextIndicator.h>
    5757#import <WebCore/ValidationBubble.h>
     58#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    5859#import <wtf/BlockPtr.h>
    5960
     
    548549    if (API::Data* data = static_cast<API::Data*>(userData)) {
    549550        auto nsData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(data->bytes())) length:data->size() freeWhenDone:NO]);
    550         auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:nsData.get()]);
    551         [unarchiver setRequiresSecureCoding:YES];
     551        auto unarchiver = secureUnarchiverFromData(nsData.get());
    552552        @try {
    553553            userObject = [unarchiver decodeObjectOfClass:[NSObject class] forKey:@"userObject"];
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm

    r218321 r223889  
    6666#import <WebCore/HTMLInputElement.h>
    6767#import <WebCore/MainFrame.h>
     68#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    6869
    6970using namespace WebCore;
     
    485486
    486487            auto data = adoptNS([[NSMutableData alloc] init]);
    487             auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    488             [archiver setRequiresSecureCoding:YES];
     488            auto archiver = secureArchiverFromMutableData(data.get());
    489489            @try {
    490490                [archiver encodeObject:userObject forKey:@"userObject"];
  • trunk/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm

    r190678 r223889  
    3535#import "WebProcessCreationParameters.h"
    3636#import <Foundation/NSBundle.h>
     37#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
    3738#import <stdio.h>
    3839#import <wtf/RetainPtr.h>
     
    8687        auto bundleParameterData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(parameters.bundleParameterData->bytes())) length:parameters.bundleParameterData->size() freeWhenDone:NO]);
    8788
    88         auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:bundleParameterData.get()]);
    89         [unarchiver setRequiresSecureCoding:YES];
     89        auto unarchiver = secureUnarchiverFromData(bundleParameterData.get());
    9090
    9191        NSDictionary *dictionary = nil;
     
    161161    auto bundleParameterData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(value.data())) length:value.size() freeWhenDone:NO]);
    162162
    163     auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:bundleParameterData.get()]);
    164     [unarchiver setRequiresSecureCoding:YES];
     163    auto unarchiver = secureUnarchiverFromData(bundleParameterData.get());
    165164
    166165    id parameter = nil;
     
    184183    auto bundleParametersData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(value.data())) length:value.size() freeWhenDone:NO]);
    185184
    186     auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:bundleParametersData.get()]);
    187     [unarchiver setRequiresSecureCoding:YES];
     185    auto unarchiver = secureUnarchiverFromData(bundleParametersData.get());
    188186
    189187    NSDictionary *parameters = nil;
Note: See TracChangeset for help on using the changeset viewer.