DedSec Project

Glossary: CI pipelines, command lines and closures — DedSec Project

Glossary: CI pipelines, command lines and closures CI How this concept behaves Automated build and test checks on changes. CI increases feedback speed but does not replace review, security…

CI

How this concept behaves

Automated build and test checks on changes. CI increases feedback speed but does not replace review, security assessment or runtime verification on actual target devices.

Work through a small example

python -m compileall -q .
python -m unittest discover -v

Investigate the behavior

Create an offline test project with one passing and one failing test and observe how CI exit codes indicate failure.

Explain a boundary case

For Continuous integration, test a second input that changes the outcome and record the expected behavior before execution. Explain which requirement fails and why the baseline example does not cover it.

CLI

How this concept behaves

Program controlled through arguments and exit status instead of a graphical interface. Good CLIs document input options, distinguish stdout/stderr and return nonzero on failure.

Work through a small example

import argparse
p=argparse.ArgumentParser();p.add_argument('--count',type=int,default=2)
assert p.parse_args(['--count','3']).count==3

Investigate the behavior

Try --help and --count wrong, capture stdout/stderr and exit status; document what another script can rely upon.

Explain a boundary case

For Command-line interface, test a second input that changes the outcome and record the expected behavior before execution. Explain which requirement fails and why the baseline example does not cover it.

Closure

Concept in practice

A closure is a function that uses names from the lexical scope in which it was created, even after that outer call returns. In Python a returned nested function holds access to the captured step value; rebinding an enclosing variable requires nonlocal, but merely reading it does not.

Focused example

def make_adder(step):
    def add(value): return value + step
    return add
plus3 = make_adder(3)
assert plus3(7) == 10

Exercise and common pitfall

Create two adders with different steps and confirm their captured values remain independent. In a loop, investigate late binding of a shared loop variable and fix it with a default argument or a factory.

Reference: https://docs.python.org/3/tutorial/classes.html#python-scopes-and-namespaces

Commit

Concept in practice

A commit is an immutable Git object identifying a tree snapshot, parent commit references and metadata. Its SHA is content-derived; a branch is only a movable pointer to a commit. Committing locally does not publish changes to a remote.

Focused example

git status --short
git add -- notes.md
git commit -m 'Explain the new test'
git show --stat --oneline HEAD

Exercise and common pitfall

Use a disposable repository to change the same file twice, produce two commits, and compare git diff HEAD~1 HEAD. Check that untracked files are excluded unless staged and that git push is a separate operation.

Reference: https://git-scm.com/book/en/v2/Git-Internals-Git-Objects

Compiler

Concept in practice

A compiler transforms source code into another representation, often machine code or bytecode. Lexing, parsing, type checking, optimization and code generation are distinct stages, and an error in one stage cannot be solved by treating every diagnostic as a runtime problem.

Focused example

#include <stdio.h>
int main(void) { puts("hello"); return 0; }

Exercise and common pitfall

Compile the program with warnings, then remove a semicolon to trigger a syntax error. Restore it and replace puts with an undeclared function to distinguish a missing declaration from a linker failure. A successful build does not prove correct behavior for all inputs.

Reference: https://gcc.gnu.org/onlinedocs/gcc/