JavaScript: Features, Trends, and Static Analysis

Similar documents
INF5750. Introduction to JavaScript and Node.js

JavaScript: Sort of a Big Deal,

hybrid security analysis of web JavaScript code via dynamic partial evaluation

JavaScript CS 4640 Programming Languages for Web Applications

A Structural Operational Semantics for JavaScript

JavaScript CS 4640 Programming Languages for Web Applications

Introduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p.

Static Analysis of JavaScript. Ben Hardekopf

Powerful JavaScript OOP concept here and now. CoffeeScript, TypeScript, etc

More on JavaScript Functions

Client-Side Web Technologies. JavaScript Part I

JavaScript. What s wrong with JavaScript?

Intro. Scheme Basics. scm> 5 5. scm>

Boot Camp JavaScript Sioux, March 31, 2011

Administrivia. Simple data types

UNIT -II. Language-History and Versions Introduction JavaScript in Perspective-

JavaScript. Training Offer for JavaScript Introduction JavaScript. JavaScript Objects

Scheme in Scheme: The Metacircular Evaluator Eval and Apply

Language Based isolation of Untrusted JavaScript

Mid-Term 2 Grades

JavaScript: Introduction, Types

The course is supplemented by numerous hands-on labs that help attendees reinforce their theoretical knowledge of the learned material.

6.184 Lecture 4. Interpretation. Tweaked by Ben Vandiver Compiled by Mike Phillips Original material by Eric Grimson

TRANSLATING DART TO EFFICIENT JAVASCRIPT. Kasper Lund Google

Lecture 3: The Basics of JavaScript. Background. Needs for Programming Capability. Origin of JavaScript. Using Client-side JavaScript

Ruby: Introduction, Basics

Turtles All The Way Down

6.037 Lecture 4. Interpretation. What is an interpreter? Why do we need an interpreter? Stages of an interpreter. Role of each part of the interpreter

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

ROSAEC Survey Workshop SELab. Soohyun Baik

Functional Programming. Pure Functional Programming

CS 360 Programming Languages Interpreters

COMP284 Scripting Languages Lecture 14: JavaScript (Part 1) Handouts

Parsing Scheme (+ (* 2 3) 1) * 1

Comp 311: Sample Midterm Examination

Why do we need an interpreter? SICP Interpretation part 1. Role of each part of the interpreter. 1. Arithmetic calculator.

JavaScript Programming

Static Analysis for JavaScript

Scheme: Data. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, Glenn G.

B l o c k B i n d i n g s

JavaScript for C# Programmers Kevin

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

CS 130(0) JavaScript Lab

Object Oriented jquery with MooTools. by Ryan Florence

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

A Structural Operational Semantics for JavaScript

Basics of JavaScript. Last Week. Needs for Programming Capability. Browser as Development Platform. Using Client-side JavaScript. Origin of JavaScript

Why Discuss JavaScript? CS312: Programming Languages. Lecture 21: JavaScript. JavaScript Target. What s a Scripting Language?

CS312: Programming Languages. Lecture 21: JavaScript

Relation Overriding. Syntax and Semantics. Simple Semantic Domains. Operational Semantics

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)

Static Analysis of Dynamically Typed Languages made Easy

Operational Semantics. One-Slide Summary. Lecture Outline

Subroutines. Subroutines. The Basics. aka: user-defined functions, methods, procdures, sub-procedures, etc etc etc.

Scripting for Multimedia LECTURE 3: INTRODUCING JAVASCRIPT

CSC Web Programming. Introduction to JavaScript

JavaScript: More Syntax

Midterm 3 practice problems

Project 5 Due 11:59:59pm Wed, Nov 25, 2015 (no late submissions)

CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures. Dan Grossman Autumn 2018

FALL 2017 CS 498RK JAVASCRIPT. Fashionable and Functional!

TAIL RECURSION, SCOPE, AND PROJECT 4 11

Today. Continue our very basic intro to JavaScript. Lambda calculus

COMP519 Web Programming Lecture 12: JavaScript (Part 3) Handouts

This document defines the ActionScript 3.0 language, which is designed to be forward- compatible with the next edition of ECMAScript (ECMA-262).

Attacking ECMAScript Engines with Redefinition. Natalie

Ruby: Introduction, Basics

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

Computer Science II (20082) Week 1: Review and Inheritance

Javascript. Daniel Zappala. CS 360 Internet Programming Brigham Young University

JavaScript: Coercion, Functions, Arrays

security analysis with WALA Omer Tripp IBM TJ Watson

Scala : an LLVM-targeted Scala compiler

React. HTML code is made up of tags. In the example below, <head> is an opening tag and </head> is the matching closing tag.

Functions & First Class Function Values

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited

DLint: Dynamically Checking Bad Coding Practices in JavaScript

Assignment 7: functions and closure conversion (part 1)

this keyword in java javatpoint

MatchaScript: Language Reference Manual Programming Languages & Translators Spring 2017

Lecture 12: Conditional Expressions and Local Binding

SEMANTIC ANALYSIS TYPES AND DECLARATIONS

CS61A Notes Week 13: Interpreters

Node.js Training JavaScript. Richard richardrodger.com

Ruby: Introduction, Basics

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Lecture 13. Notation. The rules. Evaluation Rules So Far

iwiki Documentation Release 1.0 jch

Programming language components

Principles of Programming Languages

Tamarin and ECMAScript 4. John Resig (ejohn.org) Mozilla Corporation

Basics of Using Lisp! Gunnar Gotshalks! BLU-1

Building up a language SICP Variations on a Scheme. Meval. The Core Evaluator. Eval. Apply. 2. syntax procedures. 1.

CSE 341: Programming Languages

Fall Semester, The Metacircular Evaluator. Today we shift perspective from that of a user of computer langugaes to that of a designer of

The Eval/Apply Cycle Eval. Evaluation and universal machines. Examining the role of Eval. Eval from perspective of language designer

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Notation. The rules. Evaluation Rules So Far.

Some Facts Web 2.0/Ajax Security

CS558 Programming Languages

6.001 Notes: Section 15.1

Project 5 Due 11:59:59pm Tuesday, April 25, 2017

Transcription:

JavaScript: Features, Trends, and Static Analysis Joonwon Choi ROPAS Show & Tell 01/25/2013 1

Contents What is JavaScript? Features Trends Static Analysis Conclusion & Future Works 2

What is JavaScript? Scripting language equipped with prototype, dynamic type, and first-class functions. Formalized in the ECMAScript ECMAScript JavaScript JScript ActionScript 3

Features Prototype Object Undefined / Null Type Conversion Primitive Types With / Eval Attributes Arguments First-class Function Inheritances are implemented by prototypes function Person(n) { this.setname(n); Person.prototype.setName = function(n) { this.name = n; function Student(n,s) { this.b = Person; this.b(n); delete this.b; this.studentid = s.tostring(); Student.prototype = new Person; Dynamic Type 4

Features Prototype Object Undefined / Null Type Conversion Primitive Types With / Eval Attributes Object is just a mapping from strings to values var a = new Object(); a.property = 3; assert(a.property === 3); // true assert(a[ property ] === 3); // true var s = prop ; s = s + erty ; assert(a[s] === 3); // true Arguments First-class Function Dynamic Type 5

Features Prototype Object Undefined / Null Type Conversion Primitive Types With / Eval Attributes Arguments First-class Function Dynamic Type Null is a value with a type null var a = null; assert (a === null); // true assert (a === undefined); // false var b; assert (b === null); // false assert (b === undefined); // true Pitfalls: should use appropriate operators var a = false; assert (a == null); // true assert (a === null); // false var b; assert (b == null); // true assert (b === null); // false 6

Features Prototype Object Undefined / Null Type Conversion Primitive Types With / Eval Attributes Arguments First-class Function Dynamic Type Null is a value with a type null var a = null; assert (a === null); // true assert (a === undefined); // false var b; assert (b === null); // false assert (b === undefined); // true Pitfalls: should use appropriate operators var a = false; assert (a == null); // true assert (a === null); // false var b; assert (b == null); // true assert (b === null); // false == compares only values, === compares values and types 7

Features Prototype Object Undefined / Null Type Conversion Primitive Types Type conversions are implicitly, frequently occurred, with no exceptions var a = Hello World! ; bar b = 12; a = a + b; assert (a === Hello World!12 ); // true With / Eval Attributes Arguments First-class Function Dynamic Type 8

Features Prototype Object Undefined / Null Type Conversion Primitive Types Primitive types are different from wrapped primitive types var a = Hello World ; var b = new String( Hello World ); assert (a == b); // true assert (a === b); // false With / Eval Attributes Arguments First-class Function Dynamic Type 9

Features Prototype Object Undefined / Null Type Conversion Primitive Types With / Eval Attributes Some TOO complicated features... var a = new Object(); a.property = Hello World ; with(a) { assert(property === Hello World ); // true a.eval_string = a.property = 13 ; eval(a.eval_string); assert(a.property === 13); // true Arguments First-class Function Dynamic Type 10

Features Prototype Object Undefined / Null Properties can have attributes var a = document.url; assert (a === document.url); // true document.url = Hello World ; // impossible, ReadOnly Type Conversion Primitive Types With / Eval Attributes Arguments First-class Function Dynamic Type 11

Features Prototype Object Undefined / Null Type Conversion Primitive Types With / Eval Attributes Functions can have arbitrary number of args function alerter() { var s = ; for (arg in arguments) { s = s + + arg; alert(s); alerter(1, Hello, 3, World ); // alerts 1 Hello 3 World Arguments First-class Function Dynamic Type 12

Features Prototype Object Undefined / Null Type Conversion Primitive Types With / Eval Attributes Functions are first-class objects function increase(i) { return (i+1); function executor(f, i) { return f(i); var func = increase; assert(executor(func, 1) === 2); // true Arguments First-class Function Dynamic Type 13

Features Prototype Object Undefined / Null Type Conversion Primitive Types With / Eval Attributes Types can be dynamically changed var X; if (unknown_statement) { X = Object; else { X = Array; var y = new X(5); // What is the type of y? Arguments First-class Function Dynamic Type 14

Trends Prototypes Frequently used Alternative for object-oriented inheritance Analysis problem: objects prototypes can be dynamically changed 15

Trends Properties Mostly initialized during object creation, like a constructor. function Person(n) { this.setname(n); Person.prototype.setName = function(n) { this.name = n; Rarely deleted, i.e., delete operator is rarely used. 16

Trends With / Eval Without with, eval is evil. Deprecated. 17

Trends Codes & Benchmarks Codes are not too long (in web, ~5,000 lines) Existence of well-known benchmarks Chrome Experiments Top 1,000 sites 18

Static Analysis Abstract Interpretation Anders Møller, Type Analysis for JavaScript JavaScript > IR Abstracted value Value= Undef Null Bool Num String P(L) Does not treat eval 19

Static Analysis Static Taint Analysis Salvatore Guarnieri, Saving the World Wide Web from Vulnerable JavaScript Supports prototype-chain property lookups Handles lexical scoping by SSA form 20

Static Analysis Our goal To find malicious behaviors in Tizen web apps, Using source/sink analysis, May design value analysis, if necessary. On SAFE 1 IR 1) H. Lee, S. Won, J. Jin, J. Cho, S. Ryu, "SAFE: Formal Specification and Implementation of a Scalable Analysis Framework for ECMAScript," 2012 International Workshop on Foundations of Object-Oriented Languages, October 2012. 21

Conclusion & Future Works Conclusion JavaScript has a lot of complicated features. But trends may make static analysis feasible. Future Works Design a big picture of analysis Take a look into SAFE structures 22