E12010: type requires declared package capability

Category: E12xxx Security constraints · Reported in phase: PRE_IR_CHECKS · Classification: UNDECLARED_CAPABILITY · All error codes

What went wrong

A gated system type was used in a publishable package without the corresponding capability being declared. The compiler statically verifies that every use of a gated type (network, filesystem, stdio, environment, etc.) is covered by a declared capability in the package.

Capability enforcement is on for a package that declares all four of publicAccess (true for the public EK9 repository, false for a private one), version, license and capabilities. The capabilities block is what turns enforcement on; with any of the four missing, the package is not checked.

Worked examples

Compilable examples demonstrating capability declarations:

Rationale

Supply chain attacks rely on dependencies secretly accessing system resources (network, filesystem, environment variables) that their stated purpose does not require. A JSON parser that suddenly accesses TCP or EnvVars is almost certainly compromised.

EK9 makes this visible. A package under enforcement declares which gated types it uses, and the compiler verifies that its own code uses nothing else. Enforcement is per module: a dependency that adds a capability does not break your build - the change shows in its package block, and the repository tooling shows it between versions, for you to review at upgrade time.

Most packages need no capabilities. When a previously-pure package suddenly declares org.ek9.lang::TCP or org.ek9.lang::EnvVars, that is the change to look at.

Dev code (tests, fixtures) is exempt because it is never published or consumed by other packages.

A package without all four declarations (publicAccess, version, license, capabilities) is not checked: it is not entering the supply chain under capability review.

How to fix it

Add the required capability to your package block: a publishable package that uses Stdout lists "org.ek9.lang::Stdout" in its 'capabilities'. The [EXAMPLE] section below shows a package using Stdout and Stderr with an incomplete list, then with both declared.

For grouped types, declare the primary type:

  • TCP covers TCPConnection, TCPHandler, TCPReadyHandler, TCPReadyObserver, NetworkProperties
  • UDP covers UDPPacket, NetworkProperties

Networking needs TWO capabilities: it reads network identities from the environment, so a package using it declares both "org.ek9.lang::Networking" and "org.ek9.lang::EnvVars". The message names whichever is missing.

See also

  • Sensitive type and Privileged trait: E11090

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E12010: type requires declared package capability

#!ek9
defines module error.e12010.bad

  defines function

    <?-
      Using Stdout in a publishable package without the Stdout capability declared.
      Only TCP is declared, so Stdout is not covered.
    -?>
    printMessage()
      stdout <- Stdout()
      stdout.println("Hello")

    <?-
      Using Stderr in a publishable package without the Stderr capability declared.
    -?>
    logError()
      stderr <- Stderr()
      stderr.println("Error occurred")

    <?-
      A function that does not use any gated types - should compile fine.
    -?>
    pureComputation()
      <- result as Integer?
      result: 42

  defines package
    version <- 1.0.0-0
    description <- "Test publishable package with incomplete capabilities"
    license <- "MIT"
    publicAccess <- true
    capabilities <- ["org.ek9.lang::TCP"]

Fixed: Declare every capability the package uses

#!ek9
defines module error.e12010.good

  defines function

    printMessage()
      stdout <- Stdout()
      stdout.println("Hello")

    logError()
      stderr <- Stderr()
      stderr.println("Error occurred")

  defines package
    version <- 1.0.0-0
    description <- "Test publishable package with complete capabilities"
    license <- "MIT"
    publicAccess <- true
    capabilities <- ["org.ek9.lang::Stderr", "org.ek9.lang::Stdout"]

Questions and answers

These Q&A entries show E12010 and its fix: