Mitigation Strategy: Rigorous Use of Access Control Modifiers (with Jazzy in mind)
Description:
- Review Codebase: Systematically examine all Swift and Objective-C code.
- Identify Public API: Determine which elements are intended for the public API.
- Apply
public
oropen
: Mark only the intended public API withpublic
oropen
. - Apply
internal
: Useinternal
for elements within the same module. - Apply
fileprivate
: Usefileprivate
for elements within the same source file. - Apply
private
: Useprivate
for elements within the enclosing declaration. - Consistency Check: Regularly review to ensure consistent and correct usage.
- Jazzy Consideration: Keep in mind that
jazzy
will, by default, documentpublic
,open
, andinternal
elements. Useprivate
andfileprivate
to prevent documentation generation.
-
List of Threats Mitigated:
- Exposure of Internal APIs (Severity: High): Prevents internal details from being included in the generated documentation.
- Accidental Public Exposure (Severity: Medium): Reduces the risk of unintentionally making internal components public.
- Information Leakage (Severity: Medium): Limits the amount of information about internal structure.
-
Impact:
- Exposure of Internal APIs: Significantly reduces the risk (primary defense).
- Accidental Public Exposure: Significantly reduces the risk.
- Information Leakage: Significantly reduces the risk.
-
Currently Implemented:
- *Example: "Partially implemented. Access control modifiers are used in
CoreData
andNetworking
, but inconsistently inUI
andUtilities
."
- *Example: "Partially implemented. Access control modifiers are used in
-
Missing Implementation:
- *Example: "Missing in
LegacyCode
and helper classes inUtilities
.StringExtensions.swift
andDateHelpers.swift
lack consistent access control."
- *Example: "Missing in
Mitigation Strategy: Use of --min-acl
Flag
Description:
- Identify Minimum Access Level: Determine the minimum access level for documentation (usually
public
for libraries,internal
for some apps). - Modify
jazzy
Command: Add--min-acl
followed by the access level (e.g.,jazzy --min-acl public
). - Integrate into Build Process: Ensure this command is used consistently (build script or CI/CD).
- Test: Run
jazzy
and verify the documentation includes only elements with the specified level or higher.
-
List of Threats Mitigated:
- Exposure of Internal APIs (Severity: High): "Fail-safe" to prevent internal APIs from being included.
- Accidental Public Exposure (Severity: Medium): Reinforces the intended public API.
- Inconsistent Access Control (Severity: Medium): Mitigates inconsistent access control modifier use.
-
Impact:
- Exposure of Internal APIs: Significantly reduces risk (backup to access control).
- Accidental Public Exposure: Significantly reduces risk.
- Inconsistent Access Control: Moderately reduces risk.
-
Currently Implemented:
- *Example: "Implemented in
generate_docs.sh
, run as part of CI/CD."
- *Example: "Implemented in
-
Missing Implementation:
- *Example: "Not used in local development builds. Developers need to be reminded to use the flag."
Mitigation Strategy: Use of --exclude
Flag
Description:
- Identify Files/Directories to Exclude: Determine files/directories to never include (e.g., internal helpers, tests).
- Modify
jazzy
Command: Add--exclude
followed by a comma-separated list of files/directories (e.g.,jazzy --exclude Source/Internal/*,Tests/*
). - Integrate into Build Process: Ensure consistent use (build script or CI/CD).
- Test: Run
jazzy
and verify excluded files/directories are not in the documentation.
-
List of Threats Mitigated:
- Exposure of Internal APIs (Severity: High): Excludes entire code sections, regardless of access control.
- Exposure of Sensitive Code (Severity: High): Excludes files with sensitive details.
- Inclusion of Irrelevant Code (Severity: Low): Prevents test files, etc., from cluttering documentation.
-
Impact:
- Exposure of Internal APIs: Significantly reduces risk for excluded files/directories.
- Exposure of Sensitive Code: Significantly reduces risk for excluded files/directories.
- Inclusion of Irrelevant Code: Eliminates risk for excluded files/directories.
-
Currently Implemented:
- *Example: "Implemented in
generate_docs.sh
. ExcludesTests
and files matching*Internal.swift
."
- *Example: "Implemented in
-
Missing Implementation:
- *Example: "Not used to exclude specific files in
Utilities
, even though some helper classes should be excluded."
- *Example: "Not used to exclude specific files in
Mitigation Strategy: Use of //:nodoc:
Comment Tag
Description:
- Identify Elements to Exclude: Identify specific code elements to exclude, even if
public
orinternal
. - Add
//:nodoc:
Tag: Before the element, add//:nodoc:
(e.g.,//:nodoc: public func helper() { ... }
). - Test: Run
jazzy
and verify marked elements are excluded.
-
List of Threats Mitigated:
- Exposure of Specific Internal Elements (Severity: Medium): Fine-grained control over included elements.
- Temporary Exclusion (Severity: Low): Temporarily hide parts of the API.
-
Impact:
- Exposure of Specific Internal Elements: Significantly reduces risk for marked elements.
- Temporary Exclusion: Convenient for temporary hiding.
-
Currently Implemented:
- *Example: "Used sporadically, primarily in
Networking
to exclude internal helpers."
- *Example: "Used sporadically, primarily in
-
Missing Implementation:
- *Example: "Not consistently used. Many internal helpers within public classes are not marked."
Mitigation Strategy: Keep jazzy
Updated
Description:
- Check for Updates: Regularly check for new
jazzy
(and SourceKitten) versions:jazzy
GitHub repository- SourceKitten GitHub repository
- Dependency manager
- Update Dependencies: Update to new versions, following instructions.
- Test: Run
jazzy
and verify correct documentation generation, no regressions.
-
List of Threats Mitigated:
- Vulnerabilities in
jazzy
(Severity: Low to High): Updates often include security patches. - Vulnerabilities in SourceKitten (Severity: Low to High): Updating
jazzy
often updates SourceKitten. - Bugs and Compatibility Issues (Severity: Low): Updates fix bugs, improve compatibility.
- Vulnerabilities in
-
Impact:
- Vulnerabilities in
jazzy
and SourceKitten: Reduces risk (potentially significantly). - Bugs and Compatibility Issues: Improves stability and reliability.
- Vulnerabilities in
-
Currently Implemented:
- *Example: "Dependencies managed through Swift Package Manager, updates checked weekly."
-
Missing Implementation:
- *Example: "No automated update checks. Relies on manual checks."