โŒ About FreshRSS

Normal view

There are new articles available, click to refresh the page.
Before yesterdayNews from the Ada programming language world

Ada Web Application 1.0.0 is available

27 July 2014 at 17:59

Ada Web Application is a framework to build web applications.

The new version of AWA provides:

  • New countries plugin to provide country/region/city data models
  • New settings plugin to control application user settings
  • New tags plugin to easily add tags in applications
  • New <awa:tagList> and <awa:tagCloud> components for tag display
  • Add tags to the question and blog plugins
  • Add comments to the blog post

AWA can be downloaded at http://blog.vacs.fr/vacs/download.html

A live demonstration of various features provided by AWA is available at http://demo.vacs.fr/atlas

A small tutorial explains how you can easily setup a project, design the UML model, and use the features provided by the Ada Web Application framework.

New releases for Ada Util, Ada EL, Ada Security, Ada Database Objects, Ada Server Faces, Dynamo

30 December 2015 at 22:00

Ada Utility Library, Version 1.8.0

  • Added support for immediate flush and file appending to the file logger
  • Added support for RFC7231/RFC2616 date conversion
  • Improvement of configure and installation process with gprinstall (if available)
  • Added file system stat/fstat support
  • Use gcc intrinsics for atomic counters (Intel, Arm)

Download: http://download.vacs.fr/ada-util/ada-util-1.8.0.tar.gz
GitHub: https://github.com/stcarrez/ada-util

Ada EL, Version 1.6.0

  • Added support for thread local EL context
  • Improvement of configure and installation process with gprinstall (if available)

Download: http://download.vacs.fr/ada-el/ada-el-1.6.0.tar.gz
GitHub: https://github.com/stcarrez/ada-el

Ada Security, Version 1.1.2

  • Improvement of configure and installation process with gprinstall (if available)

Download: http://download.vacs.fr/ada-security/ada-security-1.1.2.tar.gz
GitHub: https://github.com/stcarrez/ada-security

Ada Database Objects, Version 1.1.0

  • Fix link issue on Fedora
  • Detect MariaDB as a replacement for MySQL
  • Improvement of configure and installation process with gprinstall (if available)

Download: http://download.vacs.fr/ada-ado/ada-ado-1.1.0.tar.gz
GitHub: https://github.com/stcarrez/ada-ado

Ada Server Faces, Version 1.1.0

  • New EL function util:formatDate
  • New request route mapping with support for URL component extraction and parameter injection in Ada beans
  • Improvement of configure, build and installation with gprinstall when available
  • Integrate jQuery 1.11.3 and jQuery UI 1.11.4
  • Integrate jQuery Chosen 1.4.2
  • New component <w:chosen> for the Chosen support
  • Added a servlet cache control filter

Download: http://download.vacs.fr/ada-asf/ada-asf-1.1.0.tar.gz
GitHub: https://github.com/stcarrez/ada-asf

Dynamo, Version 0.8.0

  • Support to generate Markdown documentation
  • Support to generate query Ada bean operations
  • Better code generation and support for UML Ada beans

Download: http://download.vacs.fr/dynamo/dynamo-0.8.0.tar.gz
GitHub: https://github.com/stcarrez/dynamo

New releases of Ada Web Application et al.

15 July 2018 at 21:17

Ada Utility Library, Version 1.9.0

  • Improvement and fixes of the JSON, XML, CSV serialization
  • Improvement of properties to also read and describe INI files
  • Add encoders to support SHA256 and HMAC-SHA256
  • Added a command package for implementation of command line tools
  • Added event timer list management
  • Fix on the HTTP curl support
  • Implementation of x-www-form-urlencoded serialization
  • Added localized date parsing

Download: http://download.vacs.fr/ada-util/ada-util-1.9.0.tar.gz

GitHub: https://github.com/stcarrez/ada-util

Ada EL, Version 1.6.1

  • Fix minor compilation warnings and build with Ada 2012

Download: http://download.vacs.fr/ada-el/ada-el-1.6.1.tar.gz

GitHub: https://github.com/stcarrez/ada-el

Ada Security, Version 1.1.2

  • OAuth 2.0 server implementation (RFC 6749)
  • Improvement of the role based security policy

Download: http://download.vacs.fr/ada-security/ada-security-1.2.0.tar.gz

GitHub: https://github.com/stcarrez/ada-security

Ada Database Objects, Version 1.2.0

  • Improvement of SQLite connection management
  • Fix logs to avoid having password in clear text in logs
  • Fix lazy object loading
  • Fix link issue on Fedora

Download: http://download.vacs.fr/ada-ado/ada-ado-1.2.0.tar.gz

GitHub: https://github.com/stcarrez/ada-ado

Ada Server Faces, Version 1.1.0

  • New EL function util:translate for translation with a resource bundle
  • New REST servlet with support for server API implementation
  • Provide pre-defined beans in ASF contexts: requestScope
  • Add support for servlet requests to retrieve the body content as a stream
  • Improvement of navigation rules to allow setting the return status
  • Moved the servlet support in a separate project: ada-servlet
  • Integrate jQuery datetime picker

Download: http://download.vacs.fr/ada-asf/ada-asf-1.2.0.tar.gz

GitHub: https://github.com/stcarrez/ada-asf

Ada Servlet, Version 1.2.0

  • New REST servlet with support for server API implementation
  • Add support for servlet requests to retrieve the body content as a stream
  • Moved the Ada Servlet implementation outside of Ada Server Faces in a separate project

Download: http://download.vacs.fr/ada-servlet/ada-servlet-1.2.0.tar.gz

GitHub: https://github.com/stcarrez/ada-servlet

Ada Wiki Engine, Version 1.1.0

  • New condition plugins for the conditional inclusion of wiki content
  • Added support for NOTOC by the TOC filter

Download: http://download.vacs.fr/ada-wiki/ada-wiki-1.1.0.tar.gz

GitHub: https://github.com/stcarrez/ada-wiki

Swagger Ada, Version 0.1.0

  • Initial implementation of Swagger OpenAPI to easily implement REST clients and servers

Download: http://download.vacs.fr/swagger-ada/swagger-ada-0.1.0.tar.gz

GitHub: https://github.com/stcarrez/swagger-ada

Dynamo, Version 0.9.0

  • New type ASF.Parts.Part in the Dynamo UML model
  • Add support to generate ASF Upload method in UML Ada beans
  • Add support to generate AWA event actions
  • Generate JSON/XML serialization code for UML classes
  • Update the 'create-database' command to support SQLite
  • Fix model generation for multiple primary keys per table
  • Add support for <exclude> patterns in the dist command
  • Add support for YAML database model files

Download: http://download.vacs.fr/dynamo/dynamo-0.9.0.tar.gz

GitHub: https://github.com/stcarrez/dynamo

AWA, Version 1.1.0

  • New trumbowyg plugin for WYSIWYG Javascript editor
  • New setup plugin for AWA application setup
  • Moved the samples to a separate project
  • New wiki plugin to write online wiki-based documentation
  • New flotcharts plugin to integraph jQuery Flot to display various graphs
  • Improvement of configure, build and installation with gprinstall when available
  • New counter plugin to track wiki page and blog post reads
  • Moved the wiki engine to Ada Wiki library
  • Support to display images in blog post
  • New image selector for wiki and blog post editors
  • Add a programmer's guide

Download: http://download.vacs.fr/ada-awa/ada-awa-1.1.0.tar.gz

GitHub: https://github.com/stcarrez/ada-awa

All these Ada projects can be downloaded individually but they are also packaged together to help in their download and build process. You can also download everything at http://download.vacs.fr/ada-awa/awa-all-1.1.0.tar.gz

After downloading the awa-all-1.1.0.tar.gz package, have a look at the Ada Web Application Programmer's Guide to learn how to build, install and start using all this.

If you don't have time to build all this, a docker container is available: https://hub.docker.com/r/ciceron/ada-awa/

New version of Ada Web Application

1 May 2020 at 20:49

The framework provides several ready to use and extendable modules that are common to many web applications. This includes the login, authentication, users, permissions, managing comments, tags, votes, documents, images. It provides a complete blog, question and answers and a wiki module.

AWA simplifies the Web Application development by taking care of user management authentication and by providing the foundations on top of which you can construct your own application. AWA provides a powerful permission management that gives flexibility to applications to grant access and protect your user's resources.

A typical architecture of an AWA application is represented by the picture below:

((Ada/awa_architecture_overview.png|awa_architecture_overview.png|C|Ada Web Application architecture)

This version of AWA integrates smoothly with Ada Keystore in order to protect the server sensitive configuration.

Ada Web Application, Version 2.0

  • Refactoring of build process and installation
  • New audit manager for database auditing
  • Support for Postgresql
  • Improvements of images and storage plugins
  • Update Trumbowyg editor to version 2.18.0
  • Update Flot library to version 4.2.0
  • Support for commands to configure, start, stop the server
  • New mail UI component <mail:attachment> to send attachments

Dynamo, Version 1.0.0

  • Improvement and fixes in the YAML database model files
  • Add support for Nullable_String type
  • Generate Postgresql SQL files from the model files
  • Add support for database record auditing
  • Add support for floating point
  • Add support for CSS and Javascript merge in the dist command

Ada Database Objects, Version 2.1.0

  • Added Is_Modified predicate on database objects
  • Fix SQLite Load_Schema to avoid loading SQLite specific tables
  • Support for Postgresql database
  • Improvement for errors reported by database drivers
  • New audit framework to track database record changes
  • Added support for floating point numbers
  • Serialize queries in JSON/XML streams

Ada Keystore, Version 1.2.0

  • Added support for Fuse with a new mount command in akt (beta!)
  • Fix the implementation to iterate with Keystore.Properties

Ada Server Faces, Version 1.4.0

  • Performance improvement for the Facelet cache
  • Integrate jQuery 3.4.1, jQuery UI 1.12.1, jQuery Chosen 1.8.7
  • New <f:validateRegex> to validate an input field with a regular expression

Ada Utility Library, Version 2.2.0

  • New Wait_Empty operation on fifo.
  • Add Get_Count and Wait operation on executors

Ada EL Library, Version 1.8.0

  • New Expand procedure to expand the properties in place

Ada Wiki Library, Version 1.2.1

  • Minor configuration and code coverage support
  • Corrections in the Markdown syntax parser

Ada Security Library, Version 1.3.0

  • Add support to extend the authenticate manager and allow to use custom authentication through the Set_Default_Factory operation.

Ada Servlet, Version 1.4.0

  • Added support to configure the web container

Ada Web Application release 2.1.0

15 November 2020 at 21:12

The framework provides several ready to use and extendable modules that are common to many web applications. This includes the login, authentication, users, permissions, managing comments, tags, votes, documents, images. It provides a complete blog, question and answers and a wiki module.

AWA simplifies the Web Application development by taking care of user management authentication and by providing the foundations on top of which you can construct your own application. AWA provides a powerful permission management that gives flexibility to applications to grant access and protect your user's resources.

A typical architecture of an AWA application is represented by the picture below:

((Ada/awa_architecture_overview.png|awa_architecture_overview.png|C|Ada Web Application architecture)

This version of AWA integrates smoothly with Ada Keystore in order to protect the server sensitive configuration.

AWA, Version 2.1.0

  • Update Trumbowyg editor to version 2.21.0
  • Fix compilation issues with GNAT 2020
  • Update mail UI component to attach external files
  • Improved setup for secure configuration with Ada Keystore
  • Use Dynamo 1.2.0, Ada Server Faces 1.4.1, Ada Servlet 1.5.0, OpenAPI Ada 0.3.0
  • Use Ada Security 1.3.1, Ada Wiki 1.3.0, Ada Database Objects 2.1.1
  • Use Ada Keystore 1.2.1, Ada EL 1.8.1, Ada Utility Library 2.3.0

Download: http://download.vacs.fr/ada-awa/ada-awa-2.1.0.tar.gz

GitHub: https://github.com/stcarrez/ada-awa

GitLab: https://gitlab.com/stcarrez/ada-awa

Dynamo, Version 1.2.0

  • Integrate ArgoUML 0.35.2-2020-07-05
  • Fix SQL generation with 'auto' generator
  • Fix XML Hibernate mapping support
  • Improvement in SQL schema generation

Download: http://download.vacs.fr/dynamo/dynamo-1.2.0.tar.gz

GitHub: https://github.com/stcarrez/dynamo

GitLab: https://gitlab.com/stcarrez/dynamo

Swagger Ada, Version 0.3.0

  • Install the openapi generator
  • Update the openapi generator to version 5.0.0
  • Update to use Swagger UI 3.36.0
  • Fixed Ada client code generator to support `FreeFormObject` and multi-path parameters
  • Add support for HTTP HEAD, OPTIONS and PATCH requests
  • Initial implementation of Swagger OpenAPI to easily implement REST clients and servers

Download: http://download.vacs.fr/swagger-ada/swagger-ada-0.3.0.tar.gz

GitHub: https://github.com/stcarrez/swagger-ada

GitLab: https://gitlab.com/stcarrez/swagger-ada

Ada Servlet, Version 1.5.0

  • Added support for PATCH and fix OPTIONS and HEAD requests
  • Added a Docker image to play with Ada Servlet

Download: http://download.vacs.fr/ada-servlet/ada-servlet-1.5.0.tar.gz

GitHub: https://github.com/stcarrez/ada-servlet

GitLab: https://github.com/stcarrez/ada-servlet

Ada Wiki Library, Version 1.3.0

  • New plugin and filter to setup and expand variables in Wiki texts
  • Add support for Markdown tables
  • Fixes in the Markdown and Creole syntax parsers
  • New Ada Wiki Engine Programmer's Guide

Download: http://download.vacs.fr/ada-wiki/ada-wiki-1.3.0.tar.gz

GitHub: https://github.com/stcarrez/ada-wiki

GitLab: https://gitlab.com/stcarrez/ada-wiki

Ada Server Faces, Version 1.4.1

  • Fix translations, compilation warnings

Download: http://download.vacs.fr/ada-asf/ada-asf-1.4.1.tar.gz

GitHub: https://github.com/stcarrez/ada-asf

GitLab: https://gitlab.com/stcarrez/ada-asf

Ada Database Objects, Version 2.1.1

  • Fix using the configuration with multiple config environments

Download: http://download.vacs.fr/ada-ado/ada-ado-2.1.1.tar.gz

GitHub: https://github.com/stcarrez/ada-ado

GitLab: https://gitlab.com/stcarrez/ada-ado

Ada EL Library, Version 1.8.1

  • Fix compilation issue with GNAT 2020

Download: http://download.vacs.fr/ada-el/ada-el-1.8.1.tar.gz

GitHub: https://github.com/stcarrez/ada-el

GitLab: https://gitlab.com/stcarrez/ada-el

Ada Utility Library, Version 2.3.0

  • New stream operations to read/write UTF-8 sequences in Wide_Wide character
  • Fix AES encryption in CFB, OFB and CTR modes
  • Add HTTP support for HEAD, OPTIONS, PATCH requests

Download: http://download.vacs.fr/ada-util/ada-util-2.3.0.tar.gz

GitHub: https://github.com/stcarrez/ada-util

GitLab: https://gitlab.com/stcarrez/ada-util

Ada Security Library, Version 1.3.1

  • Fix AWS example

Download: http://download.vacs.fr/ada-security/ada-security-1.3.1.tar.gz

GitHub: https://github.com/stcarrez/ada-security

GitLab: https://github.com/stcarrez/ada-security

All these Ada projects can be downloaded individually but they are also packaged together to help in their download and build process. You can also download everything at http://download.vacs.fr/ada-awa/awa-all-1.1.0.tar.gz

After downloading the awa-all-1.1.0.tar.gz package, have a look at the Ada Web Application Programmer's Guide to learn how to build, install and start using all this.

If you don't have time to build all this, a docker container is available: https://hub.docker.com/r/ciceron/ada-awa/

Debian packages

I've created and setup a Debian repository to give access to several Debian packages for several Ada projects that I manage. The goal is to provide some easy and ready to use packages to simplify and help in the installation of various Ada libraries.

Access to the repository

The repository packages are signed with GPG. To get the verification key and setup the apt-get tool, you should run the following command:

wget -O - https://apt.vacs.fr/apt.vacs.fr.gpg.key | sudo apt-key add -

Ubuntu 18.04 Bionic Beaver

A first repository provides Debian packages targeted at Ubuntu 18.04 bionic. They are built with the gnat-7 package and depend on libgpr1-dev, libaws3.3.2.2-dev and libxmlada-sax7-dev. Add the following line to your /etc/apt/sources.list configuration:

deb https://apt.vacs.fr/ubuntu-bionic bionic main

Ubuntu 20.04 Focal Fossa

A second repository provides Debian packages targeted at Ubuntu 20.04 focal. They are built with the gnat-9 package and depend on libgnatprj7-dev, libaws19-dev and libxmlada-sax9-dev. Add the following line to your /etc/apt/sources.list configuration:

deb https://apt.vacs.fr/ubuntu-focal focal main

Installation

Once you've added the configuration line, you can install the packages:

sudo apt-get update
sudo apt-get install -y dynamo akt libawa2-dev libawa-unit2-dev

The Ada Web Application framework contains several plugins which are provided by separate Debian packages.

sudo apt-get install -y libawa-blogs2-dev libawa-questions2-dev libawa-wikis2-dev libawa-setup2-dev

The documentation is packaged in separate Debian packages, you can install them with:

sudo apt-get install -y libawa-doc libado-doc libawa-doc libkeystoreada-doc libsecurity-doc libutilada-doc libwikiada-doc

For the curious, you may browse the repository here.

New release of AKT with Fuse support

7 March 2021 at 19:08

Data are stored in secure wallets protected and signed by their own AES-256 key.

Wallets are protected by a master key using AES-256-CBC and the wallet master key is protected by a user password. The wallet defines up to 7 slots that identify a password key that is able to unlock the master key. To open a wallet, it is necessary to unlock one of these 7 slots by providing the correct password. Wallet key slots are protected by the user's password and the PBKDF2-HMAC-256 algorithm, a random salt, a random counter and they are encrypted using AES-256-CBC. A wallet key slot can also be protected by a GPG private key.

Data stored in the wallet are protected by their own encryption keys using AES-256-CBC. Big contents are stored in several data blocks and each data block is encrypted by using its own AES-256-CBC encryption key. Encryption keys are protected by the master key using AES-256-CBC. Data blocks are then signed using HMAC-256.

A wallet can contain another wallet which is then protected by its own encryption keys and passwords (with 7 independent slots). Because the child wallet has its own master key, it is necessary to known the primary password and the child password to unlock the parent wallet first and then the child wallet.

Installation

You can install AKT by using the Debian 10 and Ubuntu 20.04 or 18.04 packages. First, setup to accept the signed packages:

wget -O - https://apt.vacs.fr/apt.vacs.fr.gpg.key | sudo apt-key add -

and choose one of the echo command according to your Linux distribution:

# Ubuntu 20.04
# echo "deb https://apt.vacs.fr/ubuntu-focal focal main" | sudo tee -a /etc/apt/sources.list.d/vacs.list
# Ubuntu 18.04
# echo "deb https://apt.vacs.fr/ubuntu-bionic bionic main" | sudo tee -a /etc/apt/sources.list.d/vacs.list
# Debian 10
# echo "deb https://apt.vacs.fr/debian-buster buster main" | sudo tee -a /etc/apt/sources.list.d/vacs.list

Then, launch the apt update command:

sudo apt-get update

and install the tool using:

sudo apt-get install -y akt

You can also build from the source by using the following commands:

sudo apt-get install -y make gnat-7 gprbuild git gnupg2 libfuse-dev
git clone --recursive https://github.com/stcarrez/ada-keystore.git
cd ada-keystore
./configure --enable-fuse

Using AKT

To setup a keystore file and protect it with your GPG key, use the following command:

akt create secure.akt --gpg your-gpg-key-id

The keystore content can be mounted as a filesystem so that the encrypted content are directly available to existing applications as regular files. The mount command starts the fuse daemon and puts the command as a background fuse daemon to serve as a fuse filesystem and make the content visible through the mount point.

akt mount secure.akt /mnt

After the mount is successful, you can copy or access any file stored in the secure keystore. By default the Fuse filesystem is configured to ask the kernel to avoid caching the decrypted content. This has an impact on the performance since every access requires to decrypt the content.

To unmount the filesystem, you must use the umount command.

umount /mnt

Sometimes, you may have to force the umount by running:

sudo umount /mnt

AWA 2.2.0

20 March 2021 at 16:33

The framework provides several ready to use and extendable modules that are common to many web applications. This includes the login, authentication, users, permissions, managing comments, tags, votes, documents, images. It provides a complete blog, question and answers and a wiki module.

AWA simplifies the Web Application development by taking care of user management authentication and by providing the foundations on top of which you can construct your own application. AWA provides a powerful permission management that gives flexibility to applications to grant access and protect your user's resources.

A typical architecture of an AWA application is represented by the picture below:

((Ada/awa_architecture_overview.png|awa_architecture_overview.png|C|Ada Web Application architecture)

This version of AWA integrates smoothly with Ada Keystore in order to protect the server sensitive configuration.

AWA, Version 2.2.0

  • Fixed the Markdown js editor configuration
  • Send an event when a blog post is published (allows customisation such as sending e-mails)
  • Use Dynamo 1.2.1, Ada Server Faces 1.4.2, Ada Servlet 1.5.1, OpenAPI Ada 0.4.0
  • Use Ada Security 1.4.0, Ada Wiki 1.3.1, Ada Database Objects 2.1.2
  • Use Ada Keystore 1.3.1, Ada EL 1.8.2, Ada Utility Library 2.4.0

Download: http://download.vacs.fr/ada-awa/ada-awa-2.2.0.tar.gz

GitHub: https://github.com/stcarrez/ada-awa

GitLab: https://gitlab.com/stcarrez/ada-awa

Dynamo, Version 1.2.1

  • Fix uninitialized float values in generated code

Download: http://download.vacs.fr/dynamo/dynamo-1.2.1.tar.gz

GitHub: https://github.com/stcarrez/dynamo

GitLab: https://gitlab.com/stcarrez/dynamo

Swagger Ada, Version 0.4.0

  • Update the openapi generator to version 5.1.0

Download: http://download.vacs.fr/swagger-ada/swagger-ada-0.4.0.tar.gz

GitHub: https://github.com/stcarrez/swagger-ada

GitLab: https://gitlab.com/stcarrez/swagger-ada

Ada Servlet, Version 1.5.1

  • Cleanup the examples
  • Fix registration and support of application with an empty registration URI

Download: http://download.vacs.fr/ada-servlet/ada-servlet-1.5.1.tar.gz

GitHub: https://github.com/stcarrez/ada-servlet

GitLab: https://github.com/stcarrez/ada-servlet

Ada Wiki Library, Version 1.3.1

  • Minor cleanup for the build

Download: http://download.vacs.fr/ada-wiki/ada-wiki-1.3.1.tar.gz

GitHub: https://github.com/stcarrez/ada-wiki

GitLab: https://gitlab.com/stcarrez/ada-wiki

Ada Server Faces, Version 1.4.2

  • Fix compilation warnings
  • Cleanup build and examples

Download: http://download.vacs.fr/ada-asf/ada-asf-1.4.2.tar.gz

GitHub: https://github.com/stcarrez/ada-asf

GitLab: https://gitlab.com/stcarrez/ada-asf

Ada Database Objects, Version 2.1.2

  • Fix uninitialized float values in generated code used by unit tests

Download: http://download.vacs.fr/ada-ado/ada-ado-2.1.2.tar.gz

GitHub: https://github.com/stcarrez/ada-ado

GitLab: https://gitlab.com/stcarrez/ada-ado

Ada EL Library, Version 1.8.2

  • Minor build cleanup

Download: http://download.vacs.fr/ada-el/ada-el-1.8.2.tar.gz

GitHub: https://github.com/stcarrez/ada-el

GitLab: https://gitlab.com/stcarrez/ada-el

Ada Utility Library, Version 2.4.0

  • Add support to customize and provide application specific log appenders (example in ada-keystore)
  • Improvement of read/write streams to chain LZMA, AES, Base64
  • Add examples to show LZMA compress+AES encryption, AES decryption+LZMA decompress
  • Fix compilation with GNAT 10
  • New package Util.Properties.Form to help in parsing application/x-www-form-urlencoded
  • Fixed the Util.Tests.Get_Test_Path semantic and use the results directory
  • Drop detection of buggy gcc 4.7.2

Download: http://download.vacs.fr/ada-util/ada-util-2.4.0.tar.gz

GitHub: https://github.com/stcarrez/ada-util

GitLab: https://gitlab.com/stcarrez/ada-util

Ada Security Library, Version 1.4.0

  • Add support to authenticate with Gitlab and GitHub
  • Update Yahoo! authenticate to use OpenId connect
  • Update the AWS demo to add Gitlab and Github

Download: http://download.vacs.fr/ada-security/ada-security-1.4.0.tar.gz

GitHub: https://github.com/stcarrez/ada-security

GitLab: https://github.com/stcarrez/ada-security

All these Ada projects can be downloaded individually but they are also packaged together to help in their download and build process. You can also download everything at http://download.vacs.fr/ada-awa/awa-all-2.2.0.tar.gz

After downloading the awa-all-2.2.0.tar.gz package, have a look at the Ada Web Application Programmer's Guide to learn how to build, install and start using all this.

If you don't have time to build all this, a docker container is available: https://hub.docker.com/r/ciceron/ada-awa/

Debian packages

I've created and setup a Debian repository to give access to several Debian packages for several Ada projects that I manage. The goal is to provide some easy and ready to use packages to simplify and help in the installation of various Ada libraries.

Access to the repository

The repository packages are signed with GPG. To get the verification key and setup the apt-get tool, you should run the following command:

wget -O - https://apt.vacs.fr/apt.vacs.fr.gpg.key | sudo apt-key add -

Ubuntu 18.04 Bionic Beaver

A first repository provides Debian packages targeted at Ubuntu 18.04 bionic. They are built with the gnat-7 package and depend on libgpr1-dev, libaws3.3.2.2-dev and libxmlada-sax7-dev. Add the following line to your /etc/apt/sources.list configuration:

deb https://apt.vacs.fr/ubuntu-bionic bionic main

Ubuntu 20.04 Focal Fossa

A second repository provides Debian packages targeted at Ubuntu 20.04 focal. They are built with the gnat-9 package and depend on libgnatprj7-dev, libaws19-dev and libxmlada-sax9-dev. Add the following line to your /etc/apt/sources.list configuration:

deb https://apt.vacs.fr/ubuntu-focal focal main

Debian 10 Buster

A third repository provides Debian packages targeted at Debian 10 buster. They are built with the gnat-8 package and depend on libgpr2-dev, libaws18-dev and libxmlada-sax8-dev. Add the following line to your /etc/apt/sources.list configuration:

deb https://apt.vacs.fr/debian-buster buster main

Installation

Once you've added the configuration line, you can install the packages:

sudo apt-get update
sudo apt-get install -y dynamo akt libawa2-dev libawa-unit2-dev

The Ada Web Application framework contains several plugins which are provided by separate Debian packages.

sudo apt-get install -y libawa-blogs2-dev libawa-questions2-dev libawa-wikis2-dev libawa-setup2-dev

The documentation is packaged in separate Debian packages, you can install them with:

sudo apt-get install -y libawa-doc libado-doc libawa-doc libkeystoreada-doc libsecurity-doc libutilada-doc libwikiada-doc

For the curious, you may browse the repository here.

New release Ada BFD 1.2.0

11 April 2021 at 18:37

The new release is a cleanup and update of the library to support newer version of GNU binutils. The main changes are below:

  • Cleanup build process and use gprinstall for installation
  • Fix build with binutils > 2.34
  • Remove invalid API: `Bfd.Set_Error_Handler`
  • Remove fake API: `Bfd.Symbols.Is_Local_Label_Name`
    1. Installation

To use the Ada BFD library, you may either build it from the sources ada-bfd-1.2.0.tar.gz(https://download.vacs.fr/ada-bfd/ada-bfd-1.2.0.tar.gz) or install the Debian packages.

To build from the sources, you need to have a working GNAT Ada compiler as well as the `binutils-dev` Debian package installed. Then, run the following commands:

```sh git clone https://github.com/stcarrez/ada-bfd.git cd ada-bfd ./configure make build check install ```

For the Debian package installation, use the configuration that corresponds to your setup:

``` deb https://apt.vacs.fr/ubuntu-bionic bionic main deb https://apt.vacs.fr/ubuntu-focal focal main deb https://apt.vacs.fr/debian-buster buster main ```

and then run:

``` sudo apt-get update

  1. Bionic: sudo apt-get install libbfdada1-dev
  2. Focal: sudo apt-get install libbfdada2-dev
  3. Buster: sudo apt-get install libbfdada3-dev

```

    1. Reading the ELF sections

Using the Ada BFD library in a projet is quite easy, the first step is to add the following line in your GNAT project file:

``` Ada with "bfdada"; ```

To access the information of a binary, you must first define an instance of the `File_Type` and open the file. You will do this as follows:

``` Ada with Bfd.Files;

 ...
 Path : constant String := "..."; --  the binary to load
 File : Bfd.Files.File_Type;
 ...
 Bfd.Files.Open (File, Path, "");

```

Looking at the ELF section is easily made by using the `Section_Iterator` provided by the `Bfd.Sections` package.

```ada with Bfd.Sections;

 ...
 Iter : Bfd.Sections.Section_Iterator := Bfd.Sections.Get_Sections (File);
 ...
 while Bfd.Sections.Has_Element (Iter) loop
   declare
      S   : constant Bfd.Sections.Section := Bfd.Sections.Element (Iter);
   begin
      Ada.Text_IO.Put_Line (Bfd.Sections.Get_Name (S));
   end;
   Bfd.Sections.Next (Iter);
 end loop;

```

The library contains several examples that show different features of the Ada BFD library:

| bfdinfo.adb(https://github.com/stcarrez/ada-bfd/blob/master/samples/bfdinfo.adb) | ./bin/bfdinfo ./bin/bfdgen | Open BFD file, get flags, list sections and symbols | | sections.adb(https://github.com/stcarrez/ada-bfd/blob/master/samples/sections.adb) | ./bin/sections ./bin/bfdgen | Display the ELF sections with the `Bfd.Sections` | | symbol.adb(https://github.com/stcarrez/ada-bfd/blob/master/samples/symbol.adb) | ./bin/symbol ./bin/bfdgen main | Read the symbol table with `Bfd.Symbols` | | disassemble.adb(https://github.com/stcarrez/ada-bfd/blob/master/samples/disassemble.adb) | ./bin/disassemble ./bin/bfdgen | Disassemble the text section with `Bfd.Disassemble` |

AWA 2.3.0

31 July 2021 at 08:53

The framework provides several ready to use and extendable modules that are common to many web applications. This includes the login, authentication, users, permissions, managing comments, tags, votes, documents, images. It provides a complete blog, question and answers and a wiki module.

AWA simplifies the Web Application development by taking care of user management authentication and by providing the foundations on top of which you can construct your own application. AWA provides a powerful permission management that gives flexibility to applications to grant access and protect your user's resources.

A typical architecture of an AWA application is represented by the picture below:

((Ada/awa_architecture_overview.png|awa_architecture_overview.png|C|Ada Web Application architecture)

This version of AWA integrates smoothly with Ada Keystore in order to protect the server sensitive configuration.

AWA, Version 2.3.0

  • Update Trumbowyg editor to version 2.23.0
  • Fix generation of og:image meta for blog articles written in Markdown
  • Fix wiki preview with latest xkhtmltoimage 0.12.6
  • Use Dynamo 1.2.2, Ada Server Faces 1.4.3, Ada Servlet 1.5.2, OpenAPI Ada 0.5.0
  • Use Ada Wiki 1.3.2, Ada Database Objects 2.2.0
  • Use Ada Keystore 1.3.2, Ada EL 1.8.3, Ada Utility Library 2.4.1

Links: Download GitHub GitLab

Dynamo, Version 1.2.2

  • Fix the SQL type definition for double on PostgreSQL
  • Fix double support and nullable entity_type
  • Fix SQL generation for a foreign key with variable length

Links: Download GitHub GitLab

Swagger Ada, Version 0.5.0

  • Fix for GNAT 2021
  • Update the openapi generator to version 5.2.0

Links: Download GitHub GitLab

Ada Servlet, Version 1.5.2

  • Fix for GNAT 2021

Links: Download GitHub GitLab

Ada Wiki Library, Version 1.3.2

  • Fix <hr> and <br> generation to follow HTML5 convention.
  • Add option -H to the render example
  • Fix for GNAT 2021

Links: Download GitHub GitLab

Ada Server Faces, Version 1.4.3

  • Add jQuery 3.6.0
  • Add a programmer's guide
  • Remove very old jQuery 1.11.3, jQuery UI 1.11.4, jQuery Chosen 1.4.2

Links: Download GitHub GitLab

Ada Database Objects, Version 2.2.0

  • Improvement of query loaders
  • Fix reading database schema with float/double values
  • Rename Get_Double into Get_Long_Float

Links: Download GitHub GitLab

Ada EL Library, Version 1.8.3

  • Fix compilation warning with GNAT 2021

Links: Download GitHub GitLab

Ada Utility Library, Version 2.4.1

  • Fix compilation issues with GNAT 2021
  • Fix serialization of Util.Beans.Objects holding arrays or maps

Links: Download GitHub GitLab

Ada Keystore, Version 1.3.2

  • Minor compilation warning fixes

Links: Download GitHub GitLab

All these Ada projects can be downloaded individually but they are also packaged together to help in their download and build process. You can also download everything at http://download.vacs.fr/ada-awa/awa-all-2.3.0.tar.gz

After downloading the awa-all-2.3.0.tar.gz package, have a look at the Ada Web Application Programmer's Guide to learn how to build, install and start using all this.

If you don't have time to build all this, a docker container is available: https://hub.docker.com/r/ciceron/ada-awa/

Debian packages

I've created and setup a Debian repository to give access to several Debian packages for several Ada projects that I manage. The goal is to provide some easy and ready to use packages to simplify and help in the installation of various Ada libraries.

Access to the repository

The repository packages are signed with GPG. To get the verification key and setup the apt-get tool, you should run the following command:

wget -O - https://apt.vacs.fr/apt.vacs.fr.gpg.key | sudo apt-key add -

Ubuntu 18.04 Bionic Beaver

A first repository provides Debian packages targeted at Ubuntu 18.04 bionic. They are built with the gnat-7 package and depend on libgpr1-dev, libaws3.3.2.2-dev and libxmlada-sax7-dev. Add the following line to your /etc/apt/sources.list configuration:

deb https://apt.vacs.fr/ubuntu-bionic bionic main

Ubuntu 20.04 Focal Fossa

A second repository provides Debian packages targeted at Ubuntu 20.04 focal. They are built with the gnat-9 package and depend on libgnatprj7-dev, libaws19-dev and libxmlada-sax9-dev. Add the following line to your /etc/apt/sources.list configuration:

deb https://apt.vacs.fr/ubuntu-focal focal main

Debian 10 Buster

A third repository provides Debian packages targeted at Debian 10 buster. They are built with the gnat-8 package and depend on libgpr2-dev, libaws18-dev and libxmlada-sax8-dev. Add the following line to your /etc/apt/sources.list configuration:

deb https://apt.vacs.fr/debian-buster buster main

Installation

Once you've added the configuration line, you can install the packages:

sudo apt-get update
sudo apt-get install -y dynamo akt libawa2-dev libawa-unit2-dev

The Ada Web Application framework contains several plugins which are provided by separate Debian packages.

sudo apt-get install -y libawa-blogs2-dev libawa-questions2-dev libawa-wikis2-dev libawa-setup2-dev

The documentation is packaged in separate Debian packages, you can install them with:

sudo apt-get install -y libawa-doc libado-doc libawa-doc libkeystoreada-doc libsecurity-doc libutilada-doc libwikiada-doc

Advanced Resource Embedder 1.2.0

23 January 2022 at 09:04
[Embedding SQL in binary](Ada/resource-embedder-bin.png)

The new release contains the following fixes:

- Fix Ada generator to be able to use other binary content types

 such as `System.Storage_Elements.Storage_Array`
- Fix Ada generator to escape special characters in strings

Since the previous version, Fabien Chouteau asked to be able to use an Ada system type to represent a binary content. This is now possible by using the following XML extract for the description to tell the resource embedder how to integrate the file and generate the Ada source code:

```XML <package>

 <resource name='Resources.Help'
           format='binary'
           type='access constant System.Storage_Elements.Storage_Array'>
   <install mode='copy'>
     <fileset dir="help">
       <include name="**/*.txt"/>
     </fileset>
   </install>
 </resource>
 ...

</package> ```

With the above description, the Ada code generator produces the following package specification:

```Ada with System.Storage_Elements; package Resources.Help is

  type Content_Access is access constant System.Storage_Elements.Storage_Array;
  type Name_Access is access constant String;
  type Name_Array is array (Natural range <>) of Name_Access;
  Names : constant Name_Array;
  function Get_Content (Name : String)
     access constant System.Storage_Elements.Storage_Array;

private

  ...

end Resources.Help; ```

This example is available in Embedding help and documentation in Ada (binary)(https://gitlab.com/stcarrez/resource-embedder/tree/master/examples/ada-help-binary). If you prefer to use `String` instead of a `Storage_Array`, have a look at the Embedding help and documentation in Ada(https://gitlab.com/stcarrez/resource-embedder/tree/master/examples/ada-help). Both examples are similar but they are exposing the file using different Ada types.

To install the tool, follow the instructions given in the initial announcement: Advanced Resource Embedder for Ada, C and Go(https://blog.vacs.fr/vacs/blogs/post.html?post=2021/06/11/Advanced-Resource-Embedder).

If you want to know more about the tool, have a look at its documentation:

  • Resource Embedder Guide(https://resource-embedder.readthedocs.io/en/latest/) PDF(https://gitlab.com/stcarrez/resource-embedder/blob/master/docs/are-book.pdf)
  • Man page: are (1)(https://gitlab.com/stcarrez/resource-embedder/blob/master/docs/are.md)

and if you have ideas for improvements, fork the project and submit a pull request!

AWA 2.4.0

7 August 2022 at 21:12

The framework provides several ready to use and extendable modules that are common to many web applications. This includes the login, authentication, users, permissions, managing comments, tags, votes, documents, images. It provides a complete blog, question and answers and a wiki module.

AWA simplifies the Web Application development by taking care of user management authentication and by providing the foundations on top of which you can construct your own application. AWA provides a powerful permission management that gives flexibility to applications to grant access and protect your user's resources.

A typical architecture of an AWA application is represented by the picture below:

[Ada Web Application architecture](Ada/awa_architecture_overview.png)
    1. Using AWA with Alire

To use AWA with Alire, you should first register a new index to get access to the AWA crates and its dependencies.

``` alr index add git+https://github.com/stcarrez/awa-alire-index name awa ```

After this command, the `alr` command should give you access to the AWA crates and you can check that with the command:

``` alr search awa ```

Once you have setup the Alire index, you can import the `awa` framework and the `dynamo` associated tool by using the following commands:

``` alr init demo cd demo alr with awa alr with dynamo alr with servletada_aws alr build ```

Note, if you are using FreeBSD, you should probably use the following command to build (because the MariaDB shared libraries are installed in `/usr/local/lib/mariadb` directory):

``` alr build -- -largs -L/usr/local/lib/mariadb ```

Once the `dynamo` tool is built, you can use it to setup your project by using the `create-project` command. To run the `dynamo` tool, you must run it by using the `alr exec` command because Alire will setup some environment variables and `PATH` that gives access to Dynamo and AWA configuration files.

``` alr exec dynamo create-project -l apache web demo [email protected] ```

Change the `demo.gpr` GNAT project that was generated by `alr` and replace `demo.adb` by `demo-server.adb`. That later source has been generated by `dynamo` and it contains everything to setup, prepare and run the Web server. Once this is done, build the application:

``` alr build ```

The Atlas AWA Demonstrator(https://github.com/stcarrez/atlas) is also available as Alire crates. Two versions are available, the `atlas` crate is using the Ada Web Server and the `atlas_ews` is using the Embedded Web Server. To play to Atlas, you can try one of the following commands:

``` alr get atlas

  1. or

alr get altas_ews ```

    1. Debian packages

Debian packages are also available for Ubuntu 20, Ubuntu 22 and Debian 11. The repository also includes a Debian package for Alire 1.2. Choose **one** of the following configuration and add it to your `/etc/apt/sources.list` configuration.

``` deb https://apt.vacs.fr/ubuntu-focal focal main

  1. or

deb https://apt.vacs.fr/ubuntu-jammy jammy main

  1. or

deb https://apt.vacs.fr/debian-bullseye bullseye main ```

And you can run the following command to accept the signed packages:

``` wget -O - https://apt.vacs.fr/apt.vacs.fr.gpg.key | sudo apt-key add - ```

      1. AWA 2.4.0(https://github.com/stcarrez/ada-awa/releases/tag/2.4.0) Download: awa-2.4.0.tar.gz(http://download.vacs.fr/ada-awa/awa-all-2.4.0.tar.gz)
 - Add support for SQL queries embedded in applications with ARE
 - Fix #20: Do not use git:// protocol
 - New EasyMDE plugin to integrate the Easy Markdown Editor
 - Update AWA blog and AWA wiki to use the EasyMDE editor for Markdown
 - Use Dynamo 1.3.0, Ada Server Faces 1.5.0, Ada Servlet 1.6.0, OpenAPI Ada 0.6.0
 - Use Ada Wiki 1.4.0, Ada Database Objects 2.3.0
 - Use Ada Keystore 1.3.3, Ada EL 1.8.5, Ada Utility Library 2.5.0
      1. Dynamo 1.3.0(https://github.com/stcarrez/dynamo/releases/tag/1.3.0) Download: dynamo-1.3.0.tar.gz(http://download.vacs.fr/dynamo/dynamo-1.3.0.tar.gz)
 - Fix #5: Generated body does not compile when an enumeration of another UML package is used
 - Fix #7: No default type for SQL generation of a column that uses an enumeration
 - Fix #9: Option or configuration to disable some SQL generation
 - Fix #10: Definition of an UML datatype with a tagged value raises an exception
 - Fix #12: Avoid emitting a full qualified type name for types declared in the current package
 - Fix #16: Improvement in Markdown documentation generator
 - Fix #17: YAML parser: accessibility check failure
 - Fix #18: Generate database operation to reload an object
 - Fix #19: Add dynamo configuration through environment support
 - Fix #20: Give access to the man page from alire
 - Fix $21: Generated procedure Create is missing overriding keyword
      1. OpenAPI Ada 0.6.0(https://github.com/stcarrez/swagger-ada/releases/tag/0.6.0) Download: openapi-ada-0.6.0.tar.gz(http://download.vacs.fr/openapi-ada/openapi-ada-0.6.0.tar.gz)
 - Rename Swagger package into OpenAPI and provide a Swagger package for compatibility
 - Update the openapi generator to version 6.0.0
 - Add support for text/plain response
 - Add support to use external Ada types in OpenAPI definitions
 - Add support for multiple response types
 - Add support for binary responses
 - Add support for Ada enum generation for OpenAPI enums
 - Integrate Swagger UI v4.13.0
      1. Ada Server Faces 1.5.0(https://github.com/stcarrez/ada-asf/releases/tag/1.5.0) Download: ada-asf-1.5.0.tar.gz(http://download.vacs.fr/ada-asf/ada-asf-1.5.0.tar.gz)

- New widget <w:progress> to display horizontal/vertical progress bars

      1. Ada Servlet 1.6.0(https://github.com/stcarrez/ada-servlet/releases/tag/1.6.0) Download: ada-servlet-1.6.0.tar.gz(http://download.vacs.fr/ada-servlet/ada-servlet-1.6.0.tar.gz)
      2.  - Fix #4: Alire servletada_aws GNAT project fails due to missing Naming rule
         - Fix #5: The Input_Line_Size_Limit parameter is not taken into account
         - Fix #6: GNAT configuration project is not correct to build with debugging
         - Fix #7: Constraint error raised when matching empty path routes
         - Fix #11: Support for Embedded Web Server
         - Fix #12: Support for multiple response types in REST operations
        
      1. Ada Security 1.4.1(https://github.com/stcarrez/ada-security/releases/tag/1.4.1) Download: ada-security-1.4.1.tar.gz(http://download.vacs.fr/ada-security/ada-security-1.4.1.tar.gz)
 - Fix Alire GNAT project to build in debug mode
 - Fix Security.Random that generates shorter random string
      1. Ada Database Objects 2.3.0(https://github.com/stcarrez/ada-ado/releases/tag/2.3.0) Download: ada-ado-2.3.0.tar.gz(http://download.vacs.fr/ada-ado/ada-ado-2.3.0.tar.gz)
 - Fix #4: Is_Loaded predicate operation is false when an object is not yet inserted in the database
 - Fix #5: Exception raised when SQLite Query_Statement is finalized if the SQL query was invalid
 - Fix #7: Update SQLite support to 3.31.1
 - Fix #8: Add SQlite busy handler to handle the SQLITE_BUSY error
 - Fix #9: Better handling of SQLITE_BUSY error
 - Fix #10: Error 'XML query file does not exist' when the query is loaded from a static embedded loader
      1. Ada Wiki Engine 1.5.0(https://github.com/stcarrez/ada-wiki/releases/tag/1.5.0) Download: ada-wiki-1.5.0.tar.gz(http://download.vacs.fr/ada-wiki/ada-wiki-1.5.0.tar.gz)
      2.  - Add support for Textile markup language
         - Rewrote the Markdown parser to better follow the Common Mark Specification
        
      1. Ada Utility Library 2.5.0(https://github.com/stcarrez/ada-util/releases/tag/2.5.0) Download: ada-util-2.5.0.tar.gz(http://download.vacs.fr/ada-util/ada-util-2.5.0.tar.gz)
 - New examples to illustrate the IO stream composition
 - New examples for JSON parser and Util.Beans.Objects
 - Add support to set environment variables when launching a process (without changing the current process environment!)
 - Add support to indent XML output streams
 - New package Util.Files.Rolling to provide a rolling file manager
 - New package Util.Beans.Objects.Iterators to easily iterate over objects
 - Add a new log appender to support rolling log files with size and time based policies
 - New operation Util.Files.Delete_Tree to delete a directory tree and work arround
   for GNAT bug gcc/63222 and gcc/56055
 - New operation Util.Files.Realpath to find the canonicalized absolute path of a file
 - New package Util.Blobs to hold binary content with reference counting
 - New package Util.Http.Headers to provide some HTTP helper operations
 - Add support for Blob in bean objects
 - Fix compilation on NetBSD 9.2
 - Fix compilation with AWS >= 22.0

Reentrant scanner and parser with Aflex and Ayacc

14 May 2023 at 19:02
[Aflex and Ayacc](Ada/Aflex-Ayacc-code.jpg)
    1. What's new in Aflex 1.6

- Support the flex options `%option output`, `%option nooutput`, `%option yywrap`, `%option noinput`,

 `%option noyywrap`, `%option unput`, `%option nounput`, `%option bufsize=NNN` to better control the
 generated `_IO` package.
- Aflex(https://github.com/Ada-France/aflex) templates provide more control for tuning the code generation and
 they are embedded with [Advanced Resource Embedder](https://gitlab.com/stcarrez/resource-embedder)
- Support to define Ada code block in the scanner that is inserted in the generated scanner - New option -P to generate a private Ada package for DFA and IO - New directive `%option reentrant` and `%yyvar` to generate a recursive scanner - New directive `%yydecl` to allow passing parameters to `YYLex`
 or change the default function name

Example of `%option` directives to tell Aflex(https://github.com/Ada-France/aflex) to avoid generating several function or procedures and customize the buffer size.

```Ada %option nounput %option noinput %option nooutput %option noyywrap %option bufsize=1024 ```

The tool supports some code block injection at various places in the generated scanner. The code block has the following syntax where `<block-name>` is the name of the code block:

```Ada %<block-name> {

 -- Put Ada code here

} ```

The `%yytype` code block can contain type declaration, function and procedure declarations. It is injected within the `YYLex` function in the declaration part. The `%yyinit` code block can contain statements that are executed at beginning of the `YYLex` function. The `%yyaction` code block can contain statements that are executed before running any action. The `%yywrap` code block can contain statements which are executed when the end of current file is reached to start parsing a next input.

    1. What's new in Ayacc 1.4

- Support the Bison `%define variable value` option to configure the parser generator - Support the Bison `%code name { ... }` directive to insert code verbatim into the output parser - Recognize some Bison variables `api.pure`, `api.private`, `parse.error`, `parse.stacksize`,

 `parse.name`, `parse.params`, `parse.yyclearin`, `parse.yyerrok`, `parse.error`
- New option `-S skeleton` to allow using an external skeleton file for the parser generator - Ayacc(https://github.com/Ada-France/ayacc) templates provide more control for tuning the code generation and
 they are embedded with [Advanced Resource Embedder](https://gitlab.com/stcarrez/resource-embedder)
- New option `-P` to generate a private Ada package for the tokens package - Improvement to allow passing parameters to `YYParse` for the grammar rules - New `%lex` directive to control the call of `YYLex` function - Fix #6: ayacc gets stuck creating an infinitely large file after encountering a comment in an action

The generator supports two code block injections, the first one `decl` is injected in the `YYParse` procedure declaration and the `init` is injected as first statements to be executed only once when the procedure is called. The syntax is borrowed from the Bison parser:

```Ada %code decl {

  -- Put Ada declarations

} %code init {

  -- Put Ada statements

} ```

Some other Bison like improvements have been introduced to control the generation of the parser code.

``` %define parse.error true %define parse.stacksize 256 %define parse.yyclearin false %define parse.yyerrok false %define parse.name MyParser ```

    1. How to use

The easiest way to use Ayacc(https://github.com/Ada-France/ayacc) and Aflex(https://github.com/Ada-France/aflex) is to use Alire(https://github.com/alire-project/alire), get the sources, build them and install them. You can do this as follows:

``` alr get aflex cd aflex_1.6.0_b3c21d99 alr build alr install alr get ayacc cd ayacc_1.4.0_c06f997f alr build alr install ```

  • UPDATE*: the `alr install` command is available only with Alire(https://github.com/alire-project/alire) 2.0.

Using these tools is done in two steps:

1. a first step to call `aflex` or `ayacc` command with the scanner file or grammar file, 2. a second step to call `gnatchop` to split the generated file in separate Ada files

For example, with a `calc_lex.l` scanner file, you would use:

``` aflex calc_lex.l gnatchop -w calc_lex.ada ```

And with a `calc.y` grammar file:

``` ayacc calc.y gnatchop -w calc.ada ```

To know more about how to write a scanner file or grammar file, have a look at Aflex 1.5 and Ayacc 1.3.0(https://blog.vacs.fr/vacs/blogs/post.html?post=2021/12/18/Aflex-1.5-and-Ayacc-1.3.0) which explains more into details some of these aspects.

    1. Highlight on reentrancy

By default Aflex(https://github.com/Ada-France/aflex) and Ayacc(https://github.com/Ada-France/ayacc) generate a scanner and a parser which use global variables declared in a generated Ada package. These global variables contain some state about the scanner such as the current file being scanned. The Ayacc(https://github.com/Ada-France/ayacc) parser generates on its side two global variables `YYLVal` and `YYVal`.

Using global variables creates some strong restrictions when using the generated scanner and parser: we can scan and parse only one file at a time. It cannot be used in a multi-thread environment unless the scan and parse is protected from concurrent access. We cannot use easily some grammars that need to recurse and parse another file such as an included file.

      1. Reentrant scanner

The reentrant scanner is created by using the `-R` option or the `%option reentrant` directive. The scanner will then need a specific declaration with a context parameter that will hold the scanner state and variables. The context parameter has its type generated in the `Lexer_IO` package. The `%yydecl` directive in the scanner file must be used to declare the `YYLex` function with its parameters. By default the name of the context variable is `Context` but you can decide to customize and change it to another name by using the `%yyvar` directive.

``` %option reentrant %yyvar Context %yydecl function YYLex (Context : in out Lexer_IO.Context_Type) return Token ```

When the `reentrant` option is activated, Aflex(https://github.com/Ada-France/aflex) will generate a first `Context_Type` limited type in the `Lexer_DFA` package and another one in the `Lexer_IO` package. The generator can probably be improved in the future to provide a single package with a single type declaration. The `Lexer_DFA` package contains the internal data structures for the scanner to maintain its state and the `Lexer_IO` package holds the input file as well as the `YYLVal` and `YYVal` values.

      1. Reentrant parser

On its side, Ayacc(https://github.com/Ada-France/ayacc) uses the `YYLVal` and `YYVal` variables. By default, it generates them in the `_tokens` package that contains the list of parser symbols. It must not generate them and it must now use the scanner `Context_Type` to hold them as well as the scanner internal state. The setup requires several steps:

1. The reentrant parser is activated by using the `%define api.pure`

  directive similar to the [bison %define](https://www.gnu.org/software/bison/manual/html_node/_0025define-Summary.html).

2. The `%lex` directive must be used to define how the `YYLex` function must be called since it now has some

  context parameter.

3. The scanner context variable must be declared somewhere, either as parameter to the `YYParse`

  procedure or as a local variable to `YYParse`.  This is done using the new `%code decl` directive
  and allows to customize the local declaration part of the `YYParse` generated procedure.

4. We must give visibility of the `YYLVal` and `YYVal` values defined in the scanner context variable.

  Again, we can do this within the `%code decl` directive.

A simple reentrant parser could be defined by using:

```Ada %define api.pure true %lex YYLex (Scanner) %code decl {

     Scanner : Lexer_IO.Context_Type;
     YYLVal  : YYSType renames Scanner.YYLVal;
     YYVal   : YYSType renames Scanner.YYVal;

} ```

However, this simple form is not really useful as you may need to open the file and setup the scanner to read from it. It is probably better to pass the scanner context as parameter to the `YYParse` procedure. For this, we can use the `%define parse.params` directive to control the procedure parameters. The reentrant parser is declared as follows:

```Ada %lex YYLex (Scanner) %define api.pure true %define parse.params "Scanner : in out Lexer_IO.Context_Type" %code decl {

     YYLVal : YYSType renames Scanner.YYLVal;
     YYVal  : YYSType renames Scanner.YYVal;

} ```

To use the reentrant parser and scanner, we only need to declare the scanner context, open the file by using the `Lexer_IO.Open_Input` procedure and call the `YYParse` procedure as follows:

```Ada

 Scanner : Lexer_IO.Context_Type;
 ...
   Lexer_IO.Open_Input (Scanner, "file-to-scan");
   YYParse (Scanner);

```

      1. Grammar examples:

To have a more complete example of a reentrant parser, you may have a look at the following files:

Ada BFD 1.3.0

20 August 2023 at 14:14
[Ada/ada-bfd-1.3.jpg](Ada/ada-bfd-1.3.jpg)
    1. Integration with Alire

For Linux users only, the Ada BFD(https://github.com/stcarrez/ada-bfd) has an associated Alire crate which allows you to use it easily. To get access to the Alire crate, you should add the AWA Alire index(https://github.com/stcarrez/awa-alire-index) in your Alire configuration as follows:

``` alr index add=https://github.com/stcarrez/awa-alire-index.git name awa ```

Then, you can get access to the crate by using

``` alr with bfdada ```

Let's see how to use this library...

    1. Declarations

The Ada BFD(https://github.com/stcarrez/ada-bfd) library provides a set of Ada bindings that give access to the BFD library. A binary file such as an object file, an executable or an archive is represented by the `Bfd.Files.File_Type` limited type. The symbol table is represented by the `Bfd.Symbols.Symbol_Table` limited type. These two types hold internal data used and managed by the BFD library.

```ada with Bfd.Files; with Bfd.Sections; with Bfd.Symbols; ...

 File    : Bfd.Files.File_Type;
 Symbols : Bfd.Symbols.Symbol_Table;

```

    1. Opening the BFD file

The first step is to use the `Open` procedure to read the object or executable file whose path is given as argument. The `File_Type` parameter will be initialized to get access to the binary file information. The `Check_Format` function must then be called to let the BFD library gather the file format information and verify that it is an object file or an executable.

```ada Bfd.Files.Open (File, Path, ""); if Bfd.Files.Check_Format (File, Bfd.Files.OBJECT) then

   ...

end if; ```

The `File_Type` uses finalization so that it will close and reclaim resources automatically.

    1. Loading the symbol table

The symbol table is loaded by using the `Read_Symbols` procedure.

```ada

  Bfd.Symbols.Read_Symbols (File, Symbols);

```

The resources used by the symbol table will be freed when the symbol table instance is finalized.

    1. Find nearest line

Once the symbol table is loaded, we can use the `Find_Nearest_Line` function to find the nearest line of a function knowing some address. This is almost a part of that function that the addr2line (1)(https://www.man7.org/linux/man-pages/man1/addr2line.1.html) command is using.

```ada File_Name, Func_Name : Ada.Strings.Unbounded.Unbounded_String; Text_Section : Bfd.Sections.Section; Line : Natural; Pc : constant Bfd.Vma_Type := ...; ...

  Text_Section := Bfd.Sections.Find_Section (File, ".text");
  Bfd.Symbols.Find_Nearest_Line (File    => File,
                                 Sec     => Text_Section,
                                 Symbols => Symbols,
                                 Addr    => Pc,
                                 Name    => File_Name,
                                 Func    => Func_Name,
                                 Line    => Line);

```

One tricky aspect of using `Find_Nearest_Line` is the fact that the address we are giving must **sometimes** be converted to an offset within the text region. With Address space layout randomization (ASLR)(https://en.wikipedia.org/wiki/Address_space_layout_randomization) a program is mapped at a random address when it executes. Before calling `Find_Nearest_Line`, we must subtract the base address of the memory region. We must now find the virtual address of the start of the text region that is mapped in memory. While the program is running, you can find the base address of the program by looking at the `/proc/self/maps` file. This special file indicates the list of memory regions used by the process with the addresses, flags and other information. Without ASLR, the program is almost always loaded at the `0x00400000` address.

``` 00400000-007f9000 r-xp 00000000 fd:01 12067645 /home/... 009f8000-009fa000 r--p 003f8000 fd:01 12067645 /home/... 009fa000-00a01000 rw-p 003fa000 fd:01 12067645 /home/... ```

But when it is mapped at a random address, we get a different address each time the program is launched:

``` 55d5983d9000-55d598592000 r--p 00000000 fc:02 1573554 /... 55d598592000-55d599376000 r-xp 001b9000 fc:02 1573554 /... 55d599376000-55d5997ed000 r--p 00f9d000 fc:02 1573554 /... 55d5997ee000-55d5998bb000 r--p 01414000 fc:02 1573554 /... 55d5998bb000-55d5998c6000 rw-p 014e1000 fc:02 1573554 /... ```

In that case, the value to use it the first address of first `r--p` region associated with the program (here `0x55d5983d9000`).

Another method to know the virtual base address is to use the dl_iterate_phdr (3)(https://man7.org/linux/man-pages/man3/dl_iterate_phdr.3.html) function and look at the shared objects which are loaded. This function must be executed by the program itself: it gets as parameter a callback function which is called for each loaded shared object and a data parameter that will be passed to the callback.

```

  1. include <dlfcn.h>

static int dl_callback (struct dl_phdr_info* info, size_t size, void* data) {

 /* VM base address is: info->dlpi_addr */
 return 0;

} ...

  dl_iterate_phdr (dl_callback, 0);

```

When the callback is called, you can get the name of the shared object by looking at `info->dlpi_name` and the virtual base address by looking at `info->dlpi_addr`.

Ada BFD(https://github.com/stcarrez/ada-bfd) is a very specific library that is not always easy to use due to the complexity of binary program representation (ELF, DWARF, ...) and program execution. It is however used in very specific contexts such as the Muen Separation Kernel(https://muen.codelabs.ch/) and the Memory Analysis Tool(https://github.com/stcarrez/mat).

โŒ
โŒ