aws-samples / protecting-workloads-workshop
Source Code Overview

Analysis scope, overview of main, test, generated, deployment, build, and other code.

Source Code Analysis Scope
Files includes and excluded from analyses
txt
nuspec
  • 14 extensions are included in analyses: js, less, md, php, json, html, css, txt, svg, yml, gitignore, py, nuspec, ps1
  • 15 criteria are used to exclude files from analysis:
    • exclude files with path like ".*/[.][a-zA-Z0-9_]+.*" (Hidden files and folders) (2 files).
    • exclude files with path like ".*/docs/.*" (Documentation) (25 files).
    • exclude files with path like ".*/docs?/_?(build|themes?|templates?|static)/.*" (Sphinx) (0 files).
    • exclude files with path like ".*/git[-]history[.]txt" (Git history) (1 file).
    • exclude files with path like ".*/git[-][a-zA-Z0-9_]+[.]txt" (Git data exports for sokrates analyses) (0 files).
    • exclude files with path like ".*/dist/.*" (Distributions) (8 files).
    • exclude files with path like "(?i).*/jquery.*[.]js" (jQuery files) (102 files).
    • exclude files with path like ".*jquery[.].*[.]js" (jQuery library) (0 files).
    • exclude files with path like ".*/effects\.js" (Prototype) (0 files).
    • exclude files with path like ".*/extern(al)?/.*" (Dependencies) (1 file).
    • exclude files with path like ".*/bootstrap[.](js|css|less|scss|styl)" (Bootstrap) (1 file).
    • exclude files with path like ".*/normalize[.](css|less|scss|styl)" (Normalize css) (1 file).
    • exclude files with path like ".*[.]txt" (Text files) (3 files).
    • exclude files with path like ".*/sokrates_conventions[.]json" (Sokrates scoping conventions) (1 file).
    • exclude files with path like ".*/bootstrap[-].*" (Library) (0 files).
Overview of Analyzed Files
Basic stats on analyzed files
Intro
For analysis purposes we separate files in scope into several categories: main, test, generated, deployment and build, and other.

  • The main category contains all manually created source code files that are being used in the production.
  • Files in the main category are used as input for other analyses: logical decomposition, concerns, duplication, file size, unit size, and conditional complexity.
  • Test source code files are used only for testing of the product. These files are normally not deployed to production.
  • Build and deployment source code files are used to configure or support build and deployment process.
  • Generated source code files are automatically generated files that have not been manually changed after generation.
  • While a source code folder may contain a number of files, we are primarily interested in the source code files that are being written and maintained by developers.
  • Files containing binaries, documentation, or third-party libraries, for instance, are excluded from analysis. The exception are third-party libraries that have been changed by developers.

main9363 LOC (61%) 110 files
test0 LOC (0%) 0 files
generated2679 LOC (17%) 1 files
build and deployment67 LOC (<1%) 3 files
other3203 LOC (20%) 15 files
Main Code
All manually created or maintained source code that defines logic of the product that is run in a production environment.
Explore:   circles  |  sunburst
  • The following criteria are used to filter files:
    • files with paths like ".*".
  • 110 files match defined criteria (9,363 lines of code, 100.0% vs. main code):
    • 69 *.less files (5,374 lines of code)
    • 19 *.js files (2,368 lines of code)
    • 3 *.yml files (1,040 lines of code)
    • 5 *.html files (301 lines of code)
    • 10 *.php files (143 lines of code)
    • 2 *.py files (117 lines of code)
    • 1 *.css files (14 lines of code)
    • 1 *.ps1 files (6 lines of code)
  • " *.less" is biggest, containing 57.4% of code.
  • " *.ps1" is smallest, containing 0.06% of code.


*.less5374 LOC (57%) 69 files
*.js2368 LOC (25%) 19 files
*.yml1040 LOC (11%) 3 files
*.html301 LOC (3%) 5 files
*.php143 LOC (1%) 10 files
*.py117 LOC (1%) 2 files
*.css14 LOC (<1%) 1 files
*.ps16 LOC (<1%) 1 files
Generated Code
Automatically generated files, not manually changed after generation.
Explore:   circles  |  sunburst
  • The following criteria are used to filter files:
    • files with paths like ".*/npm[-]shrinkwrap[.]json".
  • 1 file matches defined criteria (2,679 lines of code, 28.6% vs. main code). All matches are in *.json files.


*.json2679 LOC (100%) 1 files
Build and Deployment Code
Source code used to configure or support build and deployment process.
nuspec
Explore:   circles  |  sunburst
  • The following criteria are used to filter files:
    • files with paths like ".*[.]git[a-z]+".
    • files with paths like ".*/[.]gitignore".
    • files with paths like ".*/package[.]json".
    • files with paths like ".*[.]nuspec".
  • 3 files match defined criteria (67 lines of code, 0.7% vs. main code):
    • 2 *.nuspec files (56 lines of code)
    • 1 *.gitignore files (11 lines of code)
  • " *.nuspec" is biggest, containing 83.58% of code.
  • " *.gitignore" is smallest, containing 16.42% of code.


*.nuspec56 LOC (83%) 2 files
*.gitignore11 LOC (16%) 1 files
Other Code
Explore:   circles  |  sunburst
  • The following criteria are used to filter files:
    • files with paths like ".*[.]json".
    • files with paths like ".*[.]md".
    • files with paths like ".*/README[.][a-z0-9]+".
    • files with paths like ".*[.]txt".
    • files with paths like ".*/[.]gitignore".
    • files with paths like ".*/LICENSE[.][a-z0-9]+".
  • 15 files match defined criteria (3,203 lines of code, 34.2% vs. main code):
    • 8 *.json files (2,995 lines of code)
    • 7 *.md files (208 lines of code)
  • " *.json" is biggest, containing 93.51% of code.
  • " *.md" is smallest, containing 6.49% of code.


*.json2995 LOC (93%) 8 files
*.md208 LOC (6%) 7 files
Analyzers
Info about analyzers used for source code examinations.
  • *.less files are analyzed with LessAnalyzer:
    • All basic standard analyses supported (source code overview, duplication, file size, concerns, findings, metrics, controls)
    • Advanced code cleaning (empty lines and comments removed for LOC calculations, additional cleaning for duplication calculations)
    • No unit size analysis
    • No conditional complexity analysis
    • No dependency analysis
  • *.js files are analyzed with JavaScriptAnalyzer:
    • All basic standard analyses supported (source code overview, duplication, file size, concerns, findings, metrics, controls)
    • Advanced code cleaning (empty lines and comments removed for LOC calculations, additional cleaning for duplication calculations)
    • Unit size analysis
    • Conditional complexity analysis
    • No dependency analysis
  • *.yml files are analyzed with YamlAnalyzer:
    • All basic standard analyses supported (source code overview, duplication, file size, concerns, findings, metrics, controls)
    • Advanced code cleaning (empty lines and comments removed for LOC calculations, additional cleaning for duplication calculations)
    • No unit size analysis
    • No conditional complexity analysis
    • No dependency analysis
  • *.html files are analyzed with HtmlAnalyzer:
    • All basic standard analyses supported (source code overview, duplication, file size, concerns, findings, metrics, controls)
    • Advanced code cleaning (empty lines and comments removed for LOC calculations, additional cleaning for duplication calculations)
    • Unit size analysis
    • Conditional complexity analysis
    • Advanced heuristic dependency analysis
  • *.php files are analyzed with PhpAnalyzer:
    • All basic standard analyses supported (source code overview, duplication, file size, concerns, findings, metrics, controls)
    • Advanced code cleaning (empty lines and comments removed for LOC calculations, additional cleaning for duplication calculations)
    • Unit size analysis
    • Conditional complexity analysis
    • Basic heuristic dependency analysis
  • *.py files are analyzed with PythonAnalyzer:
    • All basic standard analyses supported (source code overview, duplication, file size, concerns, findings, metrics, controls)
    • Advanced code cleaning (empty lines and comments removed for LOC calculations, additional cleaning for duplication calculations)
    • Unit size analysis
    • Conditional complexity analysis
    • Basic heuristic dependency analysis
  • *.css files are analyzed with CssAnalyzer:
    • All basic standard analyses supported (source code overview, duplication, file size, concerns, findings, metrics, controls)
    • Advanced code cleaning (empty lines and comments removed for LOC calculations, additional cleaning for duplication calculations)
    • No unit size analysis
    • No conditional complexity analysis
    • No dependency analysis
  • *.ps1 files are analyzed with DefaultLanguageAnalyzer:
    • All basic standard analyses supported (source code overview, duplication, file size, concerns, findings, metrics, controls)
    • Basic code cleaning (empty lines removed for LOC calculations and duplication calculations)
    • No unit size analysis
    • No conditional complexity analysis
    • No dependency analysis


2022-01-31 15:50