Giter VIP home page Giter VIP logo

Comments (9)

dblotsky avatar dblotsky commented on September 25, 2024

Yep, it's totally the dots in the identifier name. I'll add those.

from stringfuzz.

dblotsky avatar dblotsky commented on September 25, 2024

Fixed in c17048e.

from stringfuzz.

FedericoAureliano avatar FedericoAureliano commented on September 25, 2024

The problem pasted below gives this scanning error.

scanning error:
LPAREN '('
SYMBOL 'declare-const'
WHITESPACE ' '
'|aws:SourceArn| String)\n(declare-const |aws:SourceArn_account| String)\n(declare-const |aws:SourceArn'...

(declare-const |aws:SourceArn| String)
(declare-const |aws:SourceArn_account| String)
(declare-const |aws:SourceArn_exists| Bool)
(declare-const |aws:SourceArn_partition| String)
(declare-const |aws:SourceArn_region| String)
(declare-const |aws:SourceArn_resource| String)
(declare-const |aws:SourceArn_service| String)

; Condition: p0.0.0.0
(declare-const p0.0.0.0.condition Bool)
;(assert (= p0.0.0.0.condition (and |aws:SourceArn_exists| (= "arn:aws:myService:myRegion:123456789012:myResource/part" |aws:SourceArn|))))
(assert (= p0.0.0.0.condition (and |aws:SourceArn_exists|
	; SourceArn = arn : partition : service : region : account : resource
	(= |aws:SourceArn_partition| "aws")
	(= |aws:SourceArn_service| "myService")
	(= |aws:SourceArn_region| "myRegion")
	(= |aws:SourceArn_account| "123456789012")
	(= |aws:SourceArn_resource| "myResource/part")
)))

; Statement: p0.0
(declare-const p0.0.statement.allows Bool)
(assert (= p0.0.statement.allows p0.0.0.0.condition))

; Policy: 0
(declare-const p0.allows Bool)
(declare-const p0.denies Bool)
(declare-const p0.neutral Bool)
(assert (= p0.allows p0.0.statement.allows))
(assert (not p0.denies))
(assert (= p0.neutral (not p0.0.statement.allows)))

; Condition: p1.0.0.0
(declare-const p1.0.0.0.condition Bool)
(assert (= p1.0.0.0.condition (and |aws:SourceArn_exists| (and
	(= "aws" |aws:SourceArn_partition|)
	(str.prefixof "my" |aws:SourceArn_service|)
	;(str.in.re |aws:SourceArn_service| (re.++ (str.to.re "my") re.all))
	(and
		(str.prefixof "myR" |aws:SourceArn_region|)
		;(str.in.re |aws:SourceArn_region| (re.++ (str.to.re "myR") re.all))
		(str.suffixof "on" |aws:SourceArn_region|)
		;(str.in.re |aws:SourceArn_region| (re.++ re.all (str.to.re "on")))
	)
	(str.suffixof "012" |aws:SourceArn_account|)
	;(str.in.re |aws:SourceArn_account| (re.++ re.all (str.to.re "012")))
	))))

; Statement: p1.0
(declare-const p1.0.statement.allows Bool)
(assert (= p1.0.statement.allows p1.0.0.0.condition))

; Policy: 1
(declare-const p1.allows Bool)
(declare-const p1.denies Bool)
(declare-const p1.neutral Bool)
(assert (= p1.allows p1.0.statement.allows))
(assert (not p1.denies))
(assert (= p1.neutral (not p1.0.statement.allows)))

; aws:SourceArn invariants
;(assert (= |aws:SourceArn| (str.++ (str.++ (str.++ (str.++ (str.++ (str.++ (str.++ (str.++ (str.++ "arn:" |aws:SourceArn_partition|) ":") |aws:SourceArn_service|) ":") |aws:SourceArn_region|) ":") |aws:SourceArn_account|) ":") |aws:SourceArn_resource|)))

; Goals
(assert (or p0.neutral p0.denies))
(assert p1.allows)
(check-sat)

(get-model)

from stringfuzz.

dblotsky avatar dblotsky commented on September 25, 2024

@FedericoAureliano fixed in 5b1b855.

from stringfuzz.

FedericoAureliano avatar FedericoAureliano commented on September 25, 2024

Hey @dblotsky. Came across a few more while processing Murphy's examples.

  1. expected an argument, got RPAREN ')'
(declare-const S String)
; S not in aaabbb*
(assert (not (str.in.re S (re.++ (str.to.re "aaabbb") re.all ))))
; S in aaa*bbb*
(assert (str.in.re S (re.++ (re.++ (re.++
 (str.to.re "aaa") re.all ))
 (str.to.re "bbb") re.all )))
(check-sat) ; should be SAT
(get-model)
(get-info :reason-unknown)
  1. expected RPAREN, got IDENTIFIER 'Domainname'
(set-logic QF_S)
(set-info :status sat)

(declare-const Username String)
(declare-const Domainname String)
(declare-const Email String)

; username at most 64 chars and can't be empty
(assert (<= (str.len Username) 64))
(assert (> (str.len Username) 0))
; domain at most 256 chars and can't be empty
(assert (<= (str.len Domainname) 256))
(assert (> (str.len Domainname) 0))

; Email = Username ++ "@" ++ Domainname
(assert (= Email (str.++ Username "@" Domainname)))

; Email is matched by the following (very simplistic) pattern:
; (non-empty alphanumeric string) @ (one or more alphanumeric strings separated by periods)
(assert (str.in.re Email (re.++
	;; Username part
	(re.+ (re.union (re.range "a" "z") (re.range "A" "Z") (re.range "0" "9")))
	(str.to.re "@")
	;; Domainname part
	(re.++
		(re.+ (re.++ (re.+ (re.union (re.range "a" "z") (re.range "A" "Z") (re.range "0" "9"))) (str.to.re ".")))
		(re.+ (re.union (re.range "a" "z") (re.range "A" "Z") (re.range "0" "9")))))))

; Domainname is not a FQDN (does not contain '.')
(assert (not (str.in.re Domainname (re.++ (re.* re.all) (str.to.re ".") (re.* re.all)))))

(check-sat)
  1. expected SYMBOL, got LPAREN '('
(set-logic QF_S)
(set-info :status sat)

(declare-const key String)
(declare-const val String)

(define-fun QuoteRegex ((aRegex (RegEx String) )) ( RegEx String)
    (re.++ (re.++ (str.to.re """") aRegex) (str.to.re """")))

(assert (str.in.re key (QuoteRegex (re.* (str.to.re "a")))))

(assert (= (str.len key) 2)) 


(check-sat)
(get-model)

from stringfuzz.

dblotsky avatar dblotsky commented on September 25, 2024

@FedericoAureliano there are valid syntax errors in all 3 examples.

  1. Line 6 has incorrectly balanced parentheses. The "bbb" regex should be inside the second regex concat.
  2. Line 16 has a n-ary concat, which we do not support.
  3. Line 7 has a nested type, which (as far as I am aware) we do not support. Could be wrong on this one.

I did add better error-reporting in 8734862 though, which would help diagnose these in the future.

Please let me know how you'd like us to proceed with regard to point number 3.

from stringfuzz.

FedericoAureliano avatar FedericoAureliano commented on September 25, 2024

Can we support n-ary concat as nested binary concats? I think this is what z3 will do, no?

The error reporting looks great!

from stringfuzz.

FedericoAureliano avatar FedericoAureliano commented on September 25, 2024

New one. The unary minus sign is the culprit here.

Parsing error on line 7:
... (set-info :status unsat)
(declare-const x String)
(declare-const y String)
(assert (str.in.re x (re.+ (str.to.re "ab$!Pd"))))
(assert (str.in.re y (re.* (str.to.re "aAh'{:"))))
(assert (= (str.len x) -
-----------------------^
expected RPAREN, got SYMBOL '-'

(set-logic QF_S)
(set-info :status unsat)
(declare-const x String)
(declare-const y String)
(assert (str.in.re x (re.+ (str.to.re "ab$!Pd"))))
(assert (str.in.re y (re.* (str.to.re "aAh'{:"))))
(assert (= (str.len x) -2))
(check-sat)
(get-model)

from stringfuzz.

dblotsky avatar dblotsky commented on September 25, 2024

@FedericoAureliano does SMT-LIB support negated literals like that? I actually don't know.

Not sure how to deal with the n-ary concats issue. Z3str3 actually does parse them fine. Let's discuss this in the meeting tomorrow.

from stringfuzz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.