Skip to content

Commit

Permalink
make sandboxing improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dlo committed Sep 23, 2018
1 parent 3c2dc15 commit 4a9803f
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.downloads.read-write</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<false/>
</dict>
</plist>
4 changes: 3 additions & 1 deletion Health Data Importer XML Splitter/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>5</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.healthcare-fitness</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
Expand Down
20 changes: 17 additions & 3 deletions Health Data Importer XML Splitter/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ final class ViewController: NSViewController, NSDraggingDestination {
}

var fileName: String?
var directoryPath: String?
lazy var directoryPath: String? = {
guard let downloads = NSSearchPathForDirectoriesInDomains(.downloadsDirectory, .userDomainMask, true).first?.appending("/Split_Health_Export") else {
return nil
}

try? FileManager.default.createDirectory(atPath: downloads, withIntermediateDirectories: true, attributes: nil)
return downloads
}()

var status = Status.waiting {
didSet {
DispatchQueue.main.async {
Expand Down Expand Up @@ -187,7 +195,15 @@ extension ViewController: DragViewDelegate {
status = .unzipping

let zip = url.path
#if false
let temp = NSTemporaryDirectory()
#else
guard let temp = NSSearchPathForDirectoriesInDomains(.downloadsDirectory, .userDomainMask, true).first else {
// TODO!
return
}
#endif

directoryPath = temp
let directoryUrl = URL(fileURLWithPath: temp)

Expand Down Expand Up @@ -286,8 +302,6 @@ extension ViewController: ParserDelegate {
status = .complete
print("ended")

let temp = NSTemporaryDirectory()
directoryPath = temp
guard let directory = directoryPath,
let scriptUrl = Bundle.main.url(forResource: "zipItUp", withExtension: "sh") else {
return
Expand Down
Binary file modified Icon.sketch
Binary file not shown.
Binary file modified Warning.sketch
Binary file not shown.
9 changes: 7 additions & 2 deletions XML Splitter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@
377DDE4F2156A90D0012329F = {
CreatedOnToolsVersion = 10.0;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.HardenedRuntime = {
enabled = 1;
};
};
};
};
};
Expand Down Expand Up @@ -490,7 +495,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.lionheartsw.Health-Data-Importer-XML-Splitter";
PRODUCT_BUNDLE_IDENTIFIER = com.lionheartsw.HealthDataImporter.XMLSplitter;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.2;
Expand All @@ -512,7 +517,7 @@
INFOPLIST_FILE = "Health Data Importer XML Splitter/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.lionheartsw.Health-Data-Importer-XML-Splitter";
PRODUCT_BUNDLE_IDENTIFIER = com.lionheartsw.HealthDataImporter.XMLSplitter;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "XML Splitter/Parser.swift"
timestampString = "559359465.055531"
timestampString = "559415630.063696"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "214"
endingLineNumber = "214"
startingLineNumber = "220"
endingLineNumber = "220"
landmarkName = "parser(_:didStartElement:namespaceURI:qualifiedName:attributes:)"
landmarkType = "7">
</BreakpointContent>
Expand All @@ -26,11 +26,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "XML Splitter/Parser.swift"
timestampString = "559359465.055594"
timestampString = "559415630.063735"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "211"
endingLineNumber = "211"
startingLineNumber = "217"
endingLineNumber = "217"
landmarkName = "parser(_:didStartElement:namespaceURI:qualifiedName:attributes:)"
landmarkType = "7">
</BreakpointContent>
Expand All @@ -42,11 +42,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "XML Splitter/Parser.swift"
timestampString = "559359465.0556329"
timestampString = "559415630.063769"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "206"
endingLineNumber = "206"
startingLineNumber = "212"
endingLineNumber = "212"
landmarkName = "parser(_:didStartElement:namespaceURI:qualifiedName:attributes:)"
landmarkType = "7">
</BreakpointContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<key>Health Data Importer XML Splitter.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>4</integer>
<integer>3</integer>
</dict>
<key>XML Splitter.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
<integer>4</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
Expand Down
10 changes: 8 additions & 2 deletions XML Splitter/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ final class Parser: NSObject {
print("File System Reached Capacity")
} catch OutputStreamWriteError.writeError {
print("Write Error Occurred")
} catch {}
} catch {
print(error)
}

outputStream.close()
delegate?.chunkCompleted(part: currentChunk)
Expand Down Expand Up @@ -143,7 +145,11 @@ extension OutputStream {
if result == 0 {
throw OutputStreamWriteError.capacityReached
} else if result == -1 {
throw OutputStreamWriteError.writeError
if let error = streamError {
throw error
} else {
throw OutputStreamWriteError.writeError
}
} else {
return result
}
Expand Down

0 comments on commit 4a9803f

Please sign in to comment.