1. Project Overview & Quickstart (opnsense/core)
File: README.md
OPNsense GUI and system management
The OPNsense project invites developers to start contributing to
the code base. For your own purposes or โ even better โ to join us in
creating the best open source firewall available.
The build process has been designed to make it easy for anyone to
build and write code. The main outline of the new codebase is
available at:
https://docs.opnsense.org/development/architecture.html
Our aim is to gradually evolve to a new codebase instead of using a
big bang approach into something new.
Build tools
To create working software like OPNsense you need the sources and the
tools to build it. The build tools for OPNsense are freely available.
Notes on how to build OPNsense can be found in the tools repository:
https://github.com/opnsense/tools
Contribute
You can contribute to the project in many ways, e.g. testing
functionality, sending in bug reports or creating pull requests
directly via GitHub. Any help is always very welcome!
You can learn more about contributing on CONTRIBUTING.md.
License
OPNsense is and will always be available under the 2-Clause BSD license:
https://opensource.org/licenses/BSD-2-Clause
Every contribution made to the project must be licensed under the
same conditions in order to keep OPNsense truly free and accessible
for everybody.
Makefile targets
The repository offers a couple of targets that either tie into
tools.git build processes or are aimed at fast development.
make package
A package of the current state of the repository can be created using
this target. It may require several packages to be installed. The
target will try to assist in case of failure, e.g. when a missing file
needs to be fetched from an external location.
Several OPTIONS exist to customise the package, e.g.:
- CORE_DEPENDS: a list of required dependencies for the package
- CORE_DEPENDS_ARCH: a list of special
-required packages - CORE_ORIGIN: sets a FreeBSD compatible package/ports origin
- CORE_COMMENT: a short description of the package
- CORE_MAINTAINER: email of the package maintainer
- CORE_WWW: web url of the package
- CORE_NAME: sets a package name
Options are passed in the following form:
# make package CORE_NAME=my_new_nameIn general, options are either set to sane defaults or automatically
detected at runtime.
make update
Update will pull the latest commits from the current branch from the
upstream repository.
make upgrade
Upgrade will run the package build and replace the currently installed
package in the system.
make collect
Fetch changes from the running system for all known files.
make lint
Run several syntax checks on the repository. This is recommended
before issuing a pull request on GitHub.
make style
Run the PSR12 and PEP8 style checks on MVC PHP code and Python,
respectively.
For easier development you may want to use an OPNsense VM and install
the os-debug plugin that will offer the necessary tools.
make sweep
Run several automatic sanitizers on the code base.
File: contrib/parallel-lint/README.md
PHP Parallel Lint
This application checks syntax of PHP files in parallel.
It can output in plain text, colored text, json and checksyntax formats.
Additionally blame can be used to show commits that introduced the breakage.
Running parallel jobs in PHP is inspired by Nette framework tests.
The application is officially supported for use with PHP 5.3 to 8.1.
Table of contents
- Installation
- Example output
- History
- Command line options
- Recommended excludes for Symfony framework
- Excluding files from a scan based on the PHP version used
- How to upgrade
Installation
Install with composer as development dependency:
composer require --dev php-parallel-lint/php-parallel-lintAlternatively you can install as a standalone composer project:
composer create-project php-parallel-lint/php-parallel-lint /path/to/folder/php-parallel-lint
/path/to/folder/php-parallel-lint/parallel-lint # running toolFor colored output, install the suggested package php-parallel-lint/php-console-highlighter:
composer require --dev php-parallel-lint/php-console-highlighterSince v1.3.0, a PHAR file is also made available for each release.
This PHAR file is published as an asset for each release and can be found on the Releases page.
Example output
History
This project was originally created by @JakubOnderka and released as
jakub-onderka/php-parallel-lint.
Since then, Jakub has moved on to other interests and as of January 2020, the
second most active maintainer @grogy has taken over maintenance of the project
and given the project - and related dependencies - a new home in the PHP
Parallel Lint organisation.
It is strongly recommended for existing users of the (unmaintained)
jakub-onderka/php-parallel-lint package to switch their dependency to
php-parallel-lint/php-parallel-lint, see How to upgrade below.
Command line options
-pSpecify PHP-CGI executable to run (default: 'php').-s,--shortSet short_open_tag to On (default: Off).-a,--aspSet asp_tags to On (default: Off).-e <ext>Check only files with selected extensions separated by comma. (default: php,php3,php4,php5,phtml,phpt)-j <num>Runjobs in parallel (default: 10). --excludeExclude a file or directory. If you want exclude multiple items, use multiple exclude parameters.--colorsEnable colors in console output. (disables auto detection of color support)--no-colorsDisable colors in console output.--no-progressDisable progress in console output.--checkstyleOutput results as Checkstyle XML.--jsonOutput results as JSON string (requires PHP 5.4).--gitlabOutput results for the GitLab Code Quality Widget (requires PHP 5.4), see more in Code Quality documentation..--blameTry to show git blame for row with error.--git <git>Path to Git executable to show blame message (default: 'git').--stdinLoad files and folder to test from standard input.--ignore-failsIgnore failed tests.--show-deprecatedShow deprecations (default: Off).--syntax-error-callbackFile with syntax error callback for ability to modify error, see more in example.-h,--helpPrint this help.-V,--versionDisplay the application version
Recommended excludes for Symfony framework
To run from the command line:
vendor/bin/parallel-lint --exclude .git --exclude app --exclude vendor .Excluding files from a scan based on the PHP version used
Sometimes a particular file in a project may not comply with the project-wide minimum PHP version, like a file which is conditionally included in the project and contains PHP syntax which needs a higher PHP version to run.
This can make it complicated to run Parallel Lint in a CI context, as the excludes used in the command would have to be adjusted based on the PHP version on which the scan is being run.
PHP Parallel Lint offers a straight-forward way around this, as files can define their own minimum PHP version like so:
<?php // lint >= 7.4
// Code which contains PHP 7.4 syntax.With this comment in place, the file will be automatically skipped when PHP Parallel Lint is run on a PHP version lower than PHP 7.4.
Note: The // lint >= 7.4 comment has to be only the first line of the file and must directly follow the PHP open tag.
How to upgrade
Are you using jakub-onderka/php-parallel-lint package? You can switch to php-parallel-lint/php-parallel-lint using:
composer remove --dev jakub-onderka/php-parallel-lint
composer require --dev php-parallel-lint/php-parallel-lintFile: src/opnsense/mvc/app/models/OPNsense/Firewall/DynamicAliases/README.md
DynamicAliases
This namespace may contain simple classes which generate aliases that should be merged automatically in Firewall/Aliases.
Each class should have a collect() method returning a named array with alias registration info.
An easy example of the expected result can be found in ../static_aliases/core.json
** Note: make sure actions are "light weight" to prevent excessive api execution times.
2. Official Technical Reference & Guides (opnsense/docs)
OPNsense documentation
Welcome to the OPNsense documentation & wiki.
The purpose of this project is to provide OPNsense users with quality documentation.
Contribute
You can contribute to the project in many ways, e.g. testing
functionality, sending in bug reports or creating pull requests
directly via GitHub. Any help is always very welcome!
License
OPNsense documentation is available under the 2-Clause BSD license:
https://opensource.org/licenses/BSD-2-Clause
Every contribution made to the project must be licensed under the
same conditions in order to keep OPNsense truly free and accessible
for everybody.
Some pictures are licensed under the Creative Commons Zero (CC0) license:
https://creativecommons.org/publicdomain/zero/1.0/
Logos may be subject to additional copyrights, property
rights, trademarks etc. and may require the consent of a third party or the
license of these rights. Deciso B.V. does not represent or make any warranties
that it owns or licenses any of the mentioned, nor does it grant them.
Prepare build
On FreeBSD the following packages are required:
pkg install python py311-pip jpeg-turbo gmakeInstall Sphinx, our default theme and contrib packages:
pip install -r requirements.txt --upgradeUpdate API endpoints
A script is provided to update the api endpoint documentation, this can be
executed using:
./collect_api_endpoints.py --repo core /path/to/core/repository
./collect_api_endpoints.py --repo plugins /path/to/plugins/repositoryGenerate HTML documents
gmake html(gmake clean to flush)
Live preview of HTML documents
Use sphinx-autobuild to track source for changes and get a live preview served via http://localhost:8000.
pip install sphinx-autobuildsphinx-autobuild source build/htmlPublish BIOS ROM Images
BIOS ROM images are written to Deciso appliances using a FAT32 formatted (thumb) drive containing in its root directory
the combined contents of the source/hardware/files/BIOS_update_sources.zip file and the latest platform-specific
compressed BIOS ROM image. The BIOS_update_sources directory contains the EFI boot structure to trigger thestartup.nsh file when booting from the drive and kickstart the update using the LATEST.FD file.
The SHA256 hash of the BIOS_update.sources.zip file:
0cf1b042223482ea073a7a3599d6170be7c849ff8399936cf5a9db1ec5406dcf BIOS_update_sources.zipTo create a publishable archive, use the provided make_bios.py script and give it the platform type, version number and
source .fd file:
./make_bios.py --platform <A10|A20|A30> --version <version> --source <.FD filename>Example output:
2d5143f221fa120ef6d5c8799a90bd2c08e8238b3b9dd350327336d0605944a6 source/hardware/files/A10_v30_bios.tar.gzA SHA256 hash of the resulting compressed archive is provided for integrity checking.