Code Security Guidelines
Goals
The Ed-Fi Alliance must ensure, to the extent possible, that it releases high quality software products that operate correctly and securely in various deployment environments. In addition to periodic third-party review of applications including Ed-Fi ODS/API and Ed-Fi ODS Admin App, the following policies are designed to protect against deliberate or accidental inclusion of malicious code and security vulnerabilities. These policies cover the entire "supply chain": protecting software from the moment that code changes are accepted by the development team through the build process and final distribution (where applicable) of compiled software to the Ed-Fi Community.
Policy
- GitHub: all Ed-Fi source code is stored on GitHub
- Ed-Fi-Alliance: legacy, new code repositories should not use.
- Ed-Fi-Alliance-OSS: for open source, core software projects
- Ed-Fi-Closed: for closed source, core software projects
- Ed-Fi-Exchange-OSS: for open source non-core (Ed-Fi Exchange) software projects
- 2FA: all GitHub users in the Ed-Fi organizations are required to have two-factor authentication, enforced through GitHub itself.
- Authorization by role
- Owner: all Ed-Fi tech team staff, and contractors on a limited as-needed basis.
- Maintain: the
EdFiBuildAgent
"service account" in GitHub can have maintainer access in a repository, allowing its access token to create commits when performing version number updates or creating releases.- This account is accessible only to Ed-Fi technical staff members.
- Member:
- Ed-Fi core software contractors are granted Member in any of the organizations needed.
- Open source contributors can be granted Outside Collaborator access; this particularly useful for Ed-Fi Exchange projects.
- Each person should receive the least privilege applicable to their role on a given project.
- Access to the "Ed-Fi-Closed" organization is more restricted than the others, not only because of the closed source nature of the projects, but also due to the need to pay for GitHub user seats in this organization.
- Access rights are reviewed whenever there is a change to team composition, so that authorization can be removed when no longer needed.
- Branch Security
- The
main
branch is special and needs to be protected at all times, and must require pull requests.- Where applicable, the EdFiBuildAgent account can be allowed to bypass pull request for automation, e.g. when bumping a version number on merged code.
- All commits should be signed in order to avoid git user spoofing (see Signing Git Commits).
- All submitters must sign the Individual Contributors License Agreement.
- Linear history is required.
- All status checks should pass before merge.
- Do not allow bypassing.
- Block forced pushes.
- In order to create patch releases safely, branches named
patch-*
should receive the same protection. - Other branches are treated as feature branches and do not need branch security, as releases will not be made from those branches.
- Use Rulesets instead of Branch Protection, as they are more flexible.
- The
Exported rules from LMS-Toolkit
{
"id": 580376,
"name": "main",
"target": "branch",
"source_type": "Repository",
"source": "Ed-Fi-Exchange-OSS/LMS-Toolkit",
"enforcement": "active",
"conditions": {
"ref_name": {
"exclude": [],
"include": ["~DEFAULT_BRANCH", "refs/heads/patch-*"]
}
},
"rules": [
{
"type": "deletion"
},
{
"type": "non_fast_forward"
},
{
"type": "creation"
},
{
"type": "required_linear_history"
},
{
"type": "required_signatures"
},
{
"type": "pull_request",
"parameters": {
"required_approving_review_count": 1,
"dismiss_stale_reviews_on_push": false,
"require_code_owner_review": true,
"require_last_push_approval": true,
"required_review_thread_resolution": false
}
},
{
"type": "required_status_checks",
"parameters": {
"strict_required_status_checks_policy": false,
"required_status_checks": [
{
"context": "license/cla"
}
]
}
}
],
"bypass_actors": []
}
Rulesets is a new requirement as of 28 Mar 2024, which will be gradually enforced across the Alliance's repositories.
-
Injection of Dangerous or Malicious Code
- Pull requests on all code provide an opportunity for human review to
ensure that there is no unexpectedly functionality, such as statements
that transfer data out to a third party, change filesystem permissions, or
provide end-users with opportunities to execute code in inappropriate
contexts.
- Example of an "appropriate context" for runtime injection of executable code: Data Import's pre-processing scripts. Risk is ameliorated by placing Data Import in safe network zones and limiting user access to Ed-Fi system administrators.
- Protect against Trojan Source attacks.
- Use GitHub CodeQL as a static application security testing (SAST) tool to search for potential security vulnerabilities. ⚠️ Not available for closed source applications. Example of accidentally dangerous code
- Use an appropriate dependency review tool to ensure that libraries/packages used by an application do not have known vulnerabilities.
- Pull requests on all code provide an opportunity for human review to
ensure that there is no unexpectedly functionality, such as statements
that transfer data out to a third party, change filesystem permissions, or
provide end-users with opportunities to execute code in inappropriate
contexts.
-
Distribution
-
Compile and/or build distribution packages in the continuous integration (CI) environment (GitHub Actions) - not on a developer workstation.
-
Automate upload of built packages into an appropriate, secure, storage location:
Language / Framework Package Type Distribution Channel .NET NuGet Azure Artifacts Analytics Middle Tier zip GitHub Release Learning Standards Sync Tool zip Azure Blob Storage Python wheels PyPi TypeScript / JavaScript npm Azure Artifacts MetaEd (see box below) npm Azure Artifacts infoAzure Artifacts requires that npm packages are scoped, e.g.
@edfi/whatever
instead of justwhatever
. -
⚠️ The Alliance generally will not distribute packages from Ed-Fi Exchange repositories.
-
Procedures
- New repository setup:
- Apply all branch security rules described above.
- Carefully apply least required privilege authorization to the repository.
- Automated review:
- All core repositories should have appropriate automation workflows in
GitHub. See
Guidelines for Use of GitHub Actions
for more detail. Exceptions:
- Ed-Fi-Docker: vulnerability scanning provided by Docker Hub, rather than GitHub Actions
- Standards: do not contain source code
- Ed-Fi-Model
- Ed-Fi-Standard
- Ed-Fi-TPDM-Artifacts
- Starter Kits that do not contain any scannable code or actions:
- Ed-Fi-Starter-Kit-Assessments
- Ed-Fi-Starter-Kit-Equity
- Ideally, create the Code Scanning and Dependency Review workflows immediately on creation of a new repository.
- All core repositories should have appropriate automation workflows in
GitHub. See
Guidelines for Use of GitHub Actions
for more detail. Exceptions: