Melissa Kilby 823291a67d chore: restrict GitHub workflow permissions - future-proof (#109)
See https://github.com/swiftlang/github-workflows/issues/167 for
additional context

This approach aligns with security best practices, as detailed in the
following documentation:

-
https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions
-
https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#defining-access-for-the-github_token-scopes
-
https://openssf.org/blog/2024/08/12/mitigating-attack-vectors-in-github-workflows/


The default GITHUB_TOKEN permissions are defined at the repository
level. This PR modifies the workflow-level overrides to conform to
OpenSSF best practices -> defense in depth.

Allow me to quote OpenSSF:

https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions

> The highest score is awarded when the permissions definitions in each
workflow's yaml file are set as read-only at the top level and the
required write permissions are declared at the run-level.”

> Remediation steps
> - Set top-level permissions as read-all or contents: read as described
in GitHub's documentation.
> - Set any required write permissions at the job-level. Only set the
permissions required for that job; do not set permissions: write-all at
the job level.


Compare to the LLVM project:

Top-level: contents read, e.g.
https://github.com/swiftlang/llvm-project/blob/next/.github/workflows/build-ci-container-windows.yml#L3-L4
-> this makes it future-proof

Job-level: Allow write permissions as needed, e.g.
https://github.com/swiftlang/llvm-project/blob/next/.github/workflows/build-ci-container-windows.yml#L53-L58

Signed-off-by: Melissa Kilby <mkilby@apple.com>
2025-10-20 08:51:15 +01:00
2024-11-14 15:59:53 +00:00
2023-01-25 13:49:19 -08:00
2023-03-01 10:38:08 +00:00
2023-08-11 09:42:48 +01:00
2023-03-01 14:27:50 -08:00
2022-11-15 10:31:11 +01:00
2023-08-11 09:42:48 +01:00
2025-09-25 13:45:05 +01:00

SwiftASN1

An implementation of ASN.1 types and DER serialization.

Overview

ASN.1, and the DER encoding scheme, is a commonly used object serialization format. The most common use-cases for ASN.1 in general computing are in the cryptographic space, but there are a number of use-cases in a wide range of fields. This module provides an implementation of a number of ASN.1 types, as well as the DER serialization format for ASN.1.

ASN.1 can be used abstractly to describe essentially any kind of object. ASN.1 objects are made up of either primitive or composite (called "constructed") types. Individual scalar objects can be combined into aggregate types, and composed essentially arbitrarily to form abstract object formats.

Importantly, the ASN.1 object description does not define a specific encoding for these objects. Instead there are a wide range of possible ways to serialize or deserialize an ASN.1 object. Some of the most prominent are BER (the Basic Encoding Rules), CER (the Canonical Encoding Rules), DER (the Distinguished Encoding Rules), and XER (the XML Encoding Rules). For the cryptographic use-case DER is the standard choice, as a given ASN.1 object can be encoded in only one way under DER. This makes signing and verifying vastly easier, as it is at least in principle possible to perfectly reconstruct the serialization of a parsed object.

This module provides several moving pieces:

  1. A high-level representation of an ASN.1 object, in the form of a tree of object nodes (ASN1Node).
  2. A DER parser that can construct the ASN.1 tree from serialized bytes (DER.parse(_:)).
  3. A DER serializer that can construct serialized bytes from the ASN.1 tree (DER.Serializer).
  4. A number of built-in ASN.1 types, representing common constructs.

These moving pieces combine to provide support for the DER representation of ASN.1 suitable for a wide range of cryptographic uses.

Getting Started

To use swift-asn1, add the following dependency to your Package.swift:

dependencies: [
    .package(url: "https://github.com/apple/swift-asn1.git", .upToNextMajor(from: "1.0.0"))
]

You can then add the specific product dependency to your target:

dependencies: [
    .product(name: "SwiftASN1", package: "swift-asn1"),
]

Consult the documentation for examples of how to use the code. A number of examples are also present in the repository itself.

S
Description
Mirror of github.com/apple/swift-asn1
Readme Apache-2.0
1.2 MiB
0 Stars 1 Watchers 0 Forks
Languages
Swift 97.9%
CMake 1.9%
Shell 0.2%