HOLY SHIFT! Linda Zheng Roadmap You are here My Shift - - PowerPoint PPT Presentation

holy shift
SMART_READER_LITE
LIVE PREVIEW

HOLY SHIFT! Linda Zheng Roadmap You are here My Shift - - PowerPoint PPT Presentation

HOLY SHIFT! Linda Zheng Roadmap You are here My Shift Introduction Shift AST Experience Overview with Shift What is the Shift Project? Abstract Syntax Tree (AST) Binary Expression Identifier Identifier PLUS a + b a b


slide-1
SLIDE 1

HOLY SHIFT!

Linda Zheng

slide-2
SLIDE 2

Roadmap

Introduction Shift Overview Shift AST My Experience with Shift

You are here

slide-3
SLIDE 3

What is the Shift Project?

slide-4
SLIDE 4

Abstract Syntax Tree (AST)

Binary Expression Identifier PLUS “a” Identifier “b”

a + b

slide-5
SLIDE 5
slide-6
SLIDE 6
slide-7
SLIDE 7

Shift Parser

slide-8
SLIDE 8
  • ~100 nodes
  • Full support for ES6 features
  • Complies with ECMAScript Standard

The Shift AST

slide-9
SLIDE 9
  • So much JS code…
  • So much math...
  • Uh oh...
  • Replace all “+” with “*”

Example Use Case

slide-10
SLIDE 10

Text Find-and-Replace Problems

// ToDo: replace “+” with “*” // ToDo: replace “*” with “*”

slide-11
SLIDE 11

Text Find-and-Replace Problems

for (i = 0; i < 10; i++) { … } for (i = 0; i < 10; i**) { … }

slide-12
SLIDE 12

Text Find-and-Replace Problems

var pattern = /a+/ var pattern = /a*/

slide-13
SLIDE 13

Solution with Shift AST

Binary Expression Identifier Expression PLUS “a” Identifier Expression “b” MUL

slide-14
SLIDE 14

Next Step: Code Generator

slide-15
SLIDE 15
slide-16
SLIDE 16
  • Transformations
  • Analysis

Where Shift AST Shines

slide-17
SLIDE 17

Roadmap (again)

Introduction Shift Overview Shift AST My Experience with Shift

You are here

slide-18
SLIDE 18

Contributions to Shift

  • Generate Shift AST nodes
  • Parser
  • Reducer (single state)
  • Code Generator
  • Fuzzer
  • AST Validator
  • Serializer / Deserializer
slide-19
SLIDE 19
slide-20
SLIDE 20

Node Statement

Expression

“orphans”

➢ LiteralNumeric ➢ Array ➢ StaticMember ➢ Binary ➢ LiteralString ➢ This ➢ … ➢ If ➢ ForIn ➢ Break ➢ TryCatchFinally ➢ Return ➢ Block ➢ … ➢ BindingIdentifier ➢ FunctionBody ➢ ClassDeclaration ➢ Super ➢ Script ➢ Module ➢ …

slide-21
SLIDE 21

Function Declaration Function Expression Class Expression Class Declaration Function Expression Super Class Expression Super

slide-22
SLIDE 22
slide-23
SLIDE 23
slide-24
SLIDE 24

“{“ ObjectBinding “({x, y}=0)” (Orphans Family) ObjectExpression “({x, y})” (Expression Family) Either <Expression, Binding> Has “=” Return Expression Return Binding No “=” Transform Destructuring

ParseObject

slide-25
SLIDE 25

“[“ ArrayBinding “[x, y]=0” (Orphans Family) ArrayExpression “[x, y]” (Expression Family) Either <Expression, Binding> Has “=” Return Expression Return Binding No “=” Transform Destructuring

ParseArray

slide-26
SLIDE 26

Roadmap (final)

Introduction Shift Overview Shift AST My Experience with Shift

You are here!!!

slide-27
SLIDE 27
slide-28
SLIDE 28

Check out these Links!

Shift Website http://shift-ast.org/ Shape Github Repo https://github.com/shapesecurity