",! + w " | |||
Id | ",! + w "Request | ",! + w "Start time | ",! + w "Duration | ",! + w "
",logId," | ",! + . w "",^log(logId,"request")," | ",! + . w "",^log(logId,"start")," | ",! + . w "",$g(^log(logId,"duration"))," | ",! + . w "
You have granted access to "_consumerName_" to access your account at www.fosm.org
",! + w "Now return to "_consumerName_" to continue with the authentication process
",! + q + + +accessToken ; Public ; Provide an access token if the user has authorized the request token + ; + n query,authorization,version,nonce,signatureMethod,consumerKey,requestToken,timestamp,signature + n accessToken,accessTokenSecret,uid + ; + ; Inspect the authorization header first + s authorization=$g(%ENV("REDIRECT_HTTP_AUTHORIZATION")) + i $p(authorization," ",1)="OAuth" d + . s version=$p($p(authorization,"oauth_version=""",2),"""",1) + . s nonce=$p($p(authorization,"oauth_nonce=""",2),"""",1) + . s signatureMethod=$p($p(authorization,"oauth_signature_method=""",2),"""",1) + . s consumerKey=$p($p(authorization,"oauth_consumer_key=""",2),"""",1) + . s requestToken=$p($p(authorization,"oauth_token=""",2),"""",1) + . s timestamp=$p($p(authorization,"oauth_timestamp=""",2),"""",1) + . s signature=$p($p(authorization,"oauth_signature=""",2),"""",1) + ; + ; Otherwise it may be in the query string + i authorization="" d + . d unpackQuery^rest(.query,$p(%ENV("REQUEST_URI"),"?",2,$l(%ENV("REQUEST_URI")))) + . s version=$g(query("oauth_version")) + . s nonce=$g(query("oauth_nonce")) + . s signatureMethod=$g(query("oauth_signature_method")) + . s consumerKey=$g(query("oauth_consumer_key")) + . s requestToken=$g(query("oauth_token")) + . s timestamp=$g(query("oauth_timestamp")) + . s signature=$g(query("oauth_signature")) + ; + ; Validate that the consumer key is known to us + i consumerKey="" d error401 q + i '$d(^oauth("consumer",consumerKey)) d error401 q + ; + ; Check that the request token is one that was issued by us + i $l(requestToken)'=16 d error^http q ; Check for null or overlong tokens (typical of hacking attacks) + ; + i '$d(^oauth("request",requestToken)) d error401 q ; Not a token that we recognize + ; + ; Has it been authorized yet? + s uid=$g(^oauth("request",requestToken,"uid")) i uid="" d error401 q + ; + ; Generate an access token and another secret + s accessToken=$$token(22) + s accessTokenSecret=$$token(41) + s ^oauth("access",accessToken)="" + s ^oauth("access",accessToken,"consumerKey")=consumerKey + s ^oauth("access",accessToken,"nonce")=nonce + s ^oauth("access",accessToken,"signature")=signature + s ^oauth("access",accessToken,"signatureMethod")=signatureMethod + s ^oauth("access",accessToken,"timestamp")=timestamp + s ^oauth("access",accessToken,"requestToken")=requestToken + s ^oauth("access",accessToken,"accessTokenSecret")=accessTokenSecret + s ^oauth("access",accessToken,"uid")=uid + s ^oauth("access",accessToken,"createdAt")=$$nowZulu^date() + ; + w "Status: 200 OK",! + w "Set-Cookie: _osm_session=b15b254a2db61f53c0792d17d2eab208; path=/; HttpOnly",! + w "Content-Type: text/html",! + w "Content-Length: 95",! + w ! + w "oauth_token="_accessToken_"&oauth_token_secret="_accessTokenSecret + q + + +token(length) ; Generate random token + ; + n token,i + ; + s token="" + f i=1:1:length s token=token_$e("abcdefghijklmnopqrstuvwxyz0123456789",$r(35)+1) + q token + + diff --git a/openssl.m b/openssl.m new file mode 100644 index 0000000..0ac2c2f --- /dev/null +++ b/openssl.m @@ -0,0 +1,76 @@ +openssl ; openssl wrapper class + + +dgst(string,type) ; Public ; Generate a message digest + ; Usage: + ; s digest=$$dgst^openssl(string,type) + ; Inputs: + ; string = plain text input + ; type = message digest type (sha, sha1, sha512, etc) + ; Outputs: + ; $$dgst = digest of plain text input + ; + n i,f,g,x + ; + i $g(type)="" s type="sha1" + ; + s io=$i + s f="/tmp/openssl.digest.input."_$j_".tmp" + s g="/tmp/openssl.digest.output."_$j_".tmp" + ; + o f:NEW + u f w string + c f + ; + zsystem "/usr/bin/openssl dgst -"_type_" <"_f_" >"_g + o f + c f:DELETE + ; + o g:READ + u g r x + c g:DELETE + ; + u io + ; + q x + + + +enc(string,cipher,password,mode) ; Public + ; Usage: + ; s output=$$enc^openssl(string,cipher,password,mode) + ; Inputs: + ; string = plain text input + ; cipher = encryption cipher (bf, des, aes256, etc) + ; password = password for encryption + ; mode = e - encrypt, d - decrypt + ; Outputs: + ; $$enc = encrypted or decrypted string + ; Notes: + ; All encrypted strings are base64 encoded + ; + n i,f,g,x + ; + i string="" q "" ; Don't try to decrypt nothing + ; + i $g(cipher)="" s type="bf" + ; + s io=$i + s f="/tmp/openssl.cipher.input."_$j_".tmp" + s g="/tmp/openssl.cipher.output."_$j_".tmp" + ; + o f:NEW + u f w string + c f + ; + zsystem "/usr/bin/openssl enc -"_cipher_" -"_mode_" -a -A -salt -pass pass:"_password_" -in "_f_" -out "_g + o f + c f:DELETE + ; + o g:READ + u g r x + c g:DELETE + ; + u io + ; + q x diff --git a/osmXml.m b/osmXml.m new file mode 100644 index 0000000..e8143fc --- /dev/null +++ b/osmXml.m @@ -0,0 +1,149 @@ +osmXml ; XML Class + ; Copyright (C) 2008 Etienne Cherdlu <80n80n@gmail.com> + ; + ; This program is free software: you can redistribute it and/or modify + ; it under the terms of the GNU Affero General Public License as + ; published by the Free Software Foundation, either version 3 of the + ; License, or (at your option) any later version. + ; + ; This program is distributed in the hope that it will be useful, + ; but WITHOUT ANY WARRANTY; without even the implied warranty of + ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ; GNU Affero General Public License for more details. + ; + ; You should have received a copy of the GNU Affero General Public License + ; along with this program. If not, seeSummary | ",! + s instance="" + f d i instance="" q + . s instance=$o(^status("server",instance)) i instance="" q + . i '$d(^status("server",instance,"logId")) q + . w "",instance," | ",! + w "
Total requests: | ",! + s instance="" + f d i instance="" q + . s instance=$o(^status("server",instance)) i instance="" q + . i '$d(^status("server",instance,"logId")) q + . w "",$fn($g(^status("server",instance,"logId")),",")," | ",! + w "
Average response time: | ",! + s instance="" + f d i instance="" q + . s instance=$o(^status("server",instance)) i instance="" q + . i '$d(^status("server",instance,"logId")) q + . s responseTime=$g(^status("server",instance,"munin","responseTotal"),1)/$g(^status("server",instance,"munin","apiCalls"),1) + . w "",$j(responseTime,0,2)," | ",! + w "
Active requests: | ",! + s instance="" + f d i instance="" q + . s instance=$o(^status("server",instance)) i instance="" q + . i '$d(^status("server",instance,"logId")) q + . w "",^status("server",instance,"activeProcesses"),"/",^status("server",instance,"totalProcesses")," | ",! + w "
Data import | ",! + s instance="" + f d i instance="" q + . s instance=$o(^status("server",instance)) i instance="" q + . i '$d(^status("server",instance,"loadDiff")) q + . w "",instance," | ",! + w "
Source | ",! + ; s instance="" + ; f d i instance="" q + ; . s instance=$o(^status("loadDiff",instance)) i instance="" q + ; . w "",$g(^status("loadDiff",instance,"url"))," | ",! + ; w "
Last file | ",! + s instance="" + f d i instance="" q + . s instance=$o(^status("server",instance)) i instance="" q + . i '$d(^status("server",instance,"loadDiff")) q + . s lastFile=$g(^status("server",instance,"loadDiff","lastFile"),"000000000") + . w "",$e(lastFile,1,3),"/",$e(lastFile,4,6),"/",$e(lastFile,7,9),".osc"," | ",! + w "
Timestamp | ",! + s instance="" + f d i instance="" q + . s instance=$o(^status("server",instance)) i instance="" q + . i '$d(^status("server",instance,"loadDiff")) q + . w "",$g(^status("server",instance,"loadDiff","timestamp"))," | ",! + w "
Average file length | ",! + s instance="" + f d i instance="" q + . s instance=$o(^status("server",instance)) i instance="" q + . i '$d(^status("server",instance,"loadDiff")) q + . s files=^status("server",instance,"loadDiff","files") + . s lines=^status("server",instance,"loadDiff","lines")/files + . w "",$j(lines,0,0)," lines"," | ",! + w "
Average updates per file | ",! + f d i instance="" q + . s instance=$o(^status("server",instance)) i instance="" q + . i '$d(^status("server",instance,"loadDiff")) q + . s files=^status("server",instance,"loadDiff","files") + . s modified=^status("server",instance,"loadDiff","modified")/files + . w "",$j(modified,0,0)," elements | ",! + w "
Average deletions per file | ",! + f d i instance="" q + . s instance=$o(^status("server",instance)) i instance="" q + . i '$d(^status("server",instance,"loadDiff")) q + . s files=^status("server",instance,"loadDiff","files") + . s deleted=^status("server",instance,"loadDiff","deleted")/files + . w "",$j(deleted,0,0)," elements | ",! + w "
Average processing time | ",! + f d i instance="" q + . s instance=$o(^status("server",instance)) i instance="" q + . i '$d(^status("server",instance,"loadDiff")) q + . s files=^status("server",instance,"loadDiff","files") + . s duration=^status("server",instance,"loadDiff","duration")/files + . w "",$$minutes(duration)," | ",! + w "
Age | ",! + w "Server | ",! + w "LogId | ",! + w "pid | ",! + w "Query | ",! + w "User Agent | ",! + w "Extent | ",! + w "Time | ",! + w "Elements | ",! + ; + s count=0 + ; + s sAge="" + f d i sAge="" q + . s sAge=$o(^status("log",sAge)) i sAge="" q + . s logId="" + . f d i logId="" q + . . s logId=$o(^status("log",sAge,logId)) i logId="" q + . . s ps=$g(^status("log",sAge,logId,"ps")) + . . s count=count+1 + . . i (ps'="")!(count<999) d displayTask(sAge,logId) + ; + w "
User Agent | ",! + w "Requests | ",! + w "Average size | ",! + w "Extent | ",! + w "Response time | ",! + ; + ; Iterate the user agents by log frequency + s log="" + f d i log="" q + . s log=$o(^status("byLog",log),-1) i log="" q + . i log<100 s log="" q + . s agent="" + . f d i agent="" q + . . s agent=$o(^status("byLog",log,agent)) i agent="" q + . . s count=^status("byAgent",agent,"count") + . . s qsl=^status("byAgent",agent,"qsl") + . . s duration=^status("byAgent",agent,"duration") + . . s title="Sample request: "_$g(^status("byAgent",agent,"sampleRequest"))_" Sample UserAgent: "_$g(^status("byAgent",agent,"sampleUserAgent")) + . . w "|
",agent," | ",! + . . e w "",agent," | ",! + . . w "",$fn(log,",")," | ",! + . . w "",$fn(count/log,",",0)," | ",! + . . w "",$fn(qsl/log*6.25,",",2),"% | ",! + . . w "",$fn(duration/log,",",2)," | ",! + . . w "
User Agent | ",! + w "Size | ",! + w "Requests | ",! + ; + ; Iterate the user agents by size + s count="" + f d i count="" q + . s count=$o(^status("byCount",count),-1) i count="" q + . i count<1000 s count="" q + . s agent="" + . f d i agent="" q + . . s agent=$o(^status("byCount",count,agent)) i agent="" q + . . s log=^status("byAgent",agent,"log") + . . s title="Sample request: "_$g(^status("byAgent",agent,"sampleRequest"))_" Sample UserAgent: "_$g(^status("byAgent",agent,"sampleUserAgent")) + . . w "|
",agent," | ",! + . . e w "",agent," | ",! + . . w "",$fn(count,",")," | ",! + . . w "",$fn(log,",")," | ",! + . . w "