4 Lintering Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is static code analysis?

A

Static program analysis is the analysis of computer software
without actually running programs.
It is usually performed as
part of a code review and
is carried out at the
implementation phase of
a security development
lifecycle.
Static code analysis is
performed early in
development, before
software testing begins.
Automated tools can assist
programmers and
developers in carrying out
static analysis.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What types of static code analyzers do you know of?

A

Static code analyzers can be divided
into:
* code style analyzers
* vulnerability scanning tools
* Code performance optimizers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are style guide analyzers for?

A

Code style analyzers check code in accordance with best
practices so that real-world Ruby programmers can write code that
can be maintained by other real-world Ruby
programmers (Rubocop, reek).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are vulnerability scanning tools for?

A

Vulnerability scanning tools scan web applications—normally
from the outside—to look for security vulnerabilities such as cross-site scripting, SQL injection, and command injection (Brakeman,
Bundle-audit).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are code optimizers for?

A

Code performance improvers check speed idioms written in your
code and give advice on how to improve them (Bundle-leak, Fasterer)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is RuboCop?

A

RuboCop is a Ruby static code analyzer used to check if code
complies with Ruby community guidelines.
Out of the box, it enforces many of the rules outlined in
the Ruby Style Guide.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is The Ruby Style Guide?

A

This Ruby style guide recommends best practices so that real-world Ruby programmers can write code that can be maintained by other real-world Ruby programmers. A style guide that reflects real-world usage gets used, while a style guide that holds to an ideal that has been rejected by the people it is supposed to help risks not getting used at all - no matter how good it is.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you configure RuboCop?

A

bundle exec rubocop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you use auto-correct mode in RuboCop?

A

bundle exec rubocop -A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What extensions are there for RuboCop? Are they all
official?

A

Official Extensions:
* rubocop-performance—Performance
optimization analysis
* rubocop-rails—Rails-specific analysis
* rubocop-rspec—RSpec-specific analysis
* rubocop-minitest—Minitest-specific
analysis
* rubocop-rake—Rake-specific analysis
* rubocop-sequel—Code style checking for
Sequel gem
Third-party Extensions:
* rubocop-thread_safety—Thread-safety analysis
* rubocop-require_tools—Dynamic analysis for
missing require statements
* rubocop-i18n—i18n wrapper function analysis
(gettext and rails-i18n)
* Cookstyle—Custom cops and config defaults for Chef
Infra cookbooks
* rubocop-packaging—Upstream best practices and
coding conventions for downstream (e.g., Debian
packages) compatibility
* rubocop-sorbet—Sorbet-specific analysis

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you install RuboCop extensions?

A

Add a line for it in your Gemfile
(setting the require option to false, as
it is a standalone tool).
gem ‘rubocop-performance’, require: false
Put this into your .rubocop.yml.
require: rubocop-performance
Then use the command bundle install in
the terminal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a security vulnerability?

A

A vulnerability is a weakness that can be exploited by a threat actor, such
as an attacker, to cross privilege boundaries (i.e., perform unauthorized
actions) within a computer system. To exploit a vulnerability, an attacker
must have at least one applicable tool or technique for connecting to a
system weakness. In this regard, vulnerabilities are also known as the
attack surface.
The OWASP® Foundation works to improve the security of software
through its community-led open-source software projects. There are
hundreds of chapters worldwide—with tens of thousands of
members—that host both regional and international conferences.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How many types of vulnerabilities do you know of?

A

The Top 10 Web Application Security Risks in 2021
* Broken Access Control—Users cannot act outside of their intended permissions.
* Cryptographic Failures—Passwords, credit card numbers, health records, personal information,
and business secrets require extra protection.
* Injection—Attack technique data-driven applications, in which malicious SQL statements are
performed
* Insecure Design—Different weaknesses expressed as missing or ineffective control design
* Security Misconfiguration—Failing to implement all the security controls for an app
* Vulnerable and Outdated Components—If software is vulnerable, unsupported, or hasn’t
been updated
* Identification and Authentication Failures—Missing or ineffective multi-factor
authentication, weak passwords, etc.
* Software and Data Integrity Failures—Code and infrastructure that do not protect against
integrity violations
* Security Logging and Monitoring Failures—Application logs and APIs are not monitored
for suspicious activity.
* Server-Side Request Forgery—SSRF flaws occur whenever a web application fetches a
remote resource without validating the user-supplied URL.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What organization works to improve software security?

A

The OWASP® Foundation works to improve the security of software
through its community-led open-source software projects. There are
hundreds of chapters worldwide—with tens of thousands of
members—that host both regional and international conferences.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is Brakeman?

A

Brakeman is a free vulnerability scannerspecifically designed for
Ruby on Rails applications. It statically analyzes Rails application
code to find security issues at any stageof development.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What types of vulnerabilities can Brakeman catch?

A

Thistool will catch many known vulnerabilities,such as SQL
injection, cross-site scripting, etc.

17
Q

What is bundler-audit?

A

Patch-level verification for bundler
* Checks for vulnerable versions of gems in Gemfile.lock
* Checks for insecure gem sources (http:// and git://)
* Allows you to ignore certain advisories that have been worked
around manually

18
Q

Why should we use flag –update when running bundler-audit?

A

To start bundle-audit from an app’s
root directory, type the following
command:
bundle exec bundler-audit check –update

19
Q

What is bundler-leak?

A

Bundler-leak is a tool that provides memory leak
verification for Bundled apps..

20
Q

What is fasterer?

A

Fasterer willsuggestsome speed improvements
Please note that you shouldn’tfollow fasterer’s
suggestions blindly.
You probably shouldn’t consider using a while loop
instead of each_with_index if you’redoing a regular
Rails project. However, if you’redoing something
speed-dependent such as Rack or building yourown
framework, this acceleratormight be the way to go.

21
Q

How do you configure fasterer?

A

Add a line in your Gemfile.
gem ‘fasterer’, ‘~> 0.9.0’
Then use the command bundle install in
the terminal.
Run it from the root folder of your
project.
bundle exec fasterer
Fasterer can be controlled using the
.fasterer.yml configuration file.
This can be placed in the root folder of your
project or any ancestor folder.
For example, you can:
* turn off speed suggestions
* blacklist files or complete folder paths

22
Q

Why is it convenient to use lefthook?

A

Lefthook is a fast and powerful Git hook manager for Ruby or
Node projects.
One gem brings all linterstogether and run the before push or
commit
Lefthookallows users to keep all configs in one place as well as
reuse them locally and on testing servers or CI.

23
Q

What command installs lefthook?

A

lefthook install

24
Q

How do you configure lefthook?

A

Find the file lefthook.yml and adjust
the settings as necessary.
Add lefthook to your CI/CD pipeline or
run the following command in the
terminal:
lefthook run pre-commit

25
Q

How do you put off lefthook execution?

A

To disable lefthook temporarily, run in
the terminal:
LEFTHOOK=0 git push …
You can also skip some tags:
LEFTHOOK_EXCLUDE={list of tags}