Sunday, March 31, 2019

Intellij Dart Analysis Server Bad State: Too many elements

This error was also causing an issue "cannot find declaration to go to"
After doing a flutter upgrade, I had to do the following:

  1. Close IntelliJ
  2. delete the project's .idea folder and any *.iml files
  3. Reopen the project in intellij
If that doesn't work try File -> Invalidate caches / restart and repeat the steps above

Sunday, March 3, 2019

PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 8: null)

Using the flutter framework for android development, I received the following error during google signin:

PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 8: null)

While it wasn't obvious from the error message what the problem was, it turns out there was no network connection available. So if you get this error, check that you have access to the internet!!

Tuesday, February 19, 2019

Node.js Centos 7 production configuration


Install nodejs

Download
wget --no-check-certificate https://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.xz
Move the downloaded file /usr/local
Then unpack
tar xf node-v10.15.1-linux-x64.tar.xz
Add node executables to the path by adding symlinks to /usr/bin
ln -s /usr/local/node/bin/node /usr/bin/node
ln -s /usr/local/node/bin/npm /usr/bin/npm
ln -s /usr/local/node/bin/npx /usr/bin/npx

Install pm2

To run node as service we need to install a nodejs package
npm install pm2@latest –g
We need to run set the path to pm2
ln -s /usr/local/node/bin/pm2 /usr/bin/pm2
ln -s /usr/local/node/bin/pm2 /usr/bin/pm2-runtime

For security reasons we should run our app NOT as root. We create a new user nodejs to run our app
useradd nodejs
chown -R nodejs:nodejs /usr/local/node
chown –R nodejs:nodejs /usr/local/node-v10.15.1-linux-x64
# as root
pm2 startup system –u nodejs –-hp /home/nodjs

To start the application as the nodejs user, switch to the user nodejs
su nodejs
pm2 start /usr/local/node/apps/chat/server.js
pm2 list
# to automatically start the app on reboots
pm2 save

You should see that the app is running as user nodejs 



Likewise to stop
#other commands
pm2 stop /usr/local/node/apps/chat/server.js
pm2 delete /usr/local/node/apps/chat/server.js

Monday, February 11, 2019

Install ArangoDB on Centos 7


The instructions on the official arangodb website do not work, so I’m documenting the steps I took so that it may help others.

The first problem is adding arangodb as a repo due to invalid SSL certificates. To get around the issue:


The added ‘k’ parameter connects to the repo insecurely skipping the step of verifying the certificates.

Before we can run the yum command to install arangodb, we need to configure the arangodb.repo to skip SSL checks by adding the following to the file /etc/yum.repos.d/arangodb.repo
sslverify=0

Then run the command to install:
yum install arangodb3

References:

Monday, December 10, 2018

Grails 2.4.4 Spring tool suite STS - failed to read artifact descriptor

Recently, we started having issues downloading dependencies for our Grails projects running on Java 7 with the following error:

 failed to read artifact descriptor 
I was basically trying to run a 'grails clean' command on the project through STS eclipse (version 3.6.4). I was aware with the community finally disabling support for version TLSv1 and suspected it might be related. I made all attempts to specify TLSv1.1 and TLSv1.2 in various configurations in STS without any success. I tried in the STS eclipse INI file using the argument

-Dhttps.protocols=TLSv1.1,TLSv1.2
I also tried setting the https.protocol in the JRE definition of eclipse:

Windows -> Preferences -> Java -> Installed JREs -> jdk1.7.0_79 -> Edit -> Default VM arguments

No luck either.

I finally decided to run 'grails command' on the command-line where I had JDK version 8 running by default:


C:\grails\grails-2.4.4\bin\grails clean
| JVM Version: 1.8.0_171
| Application cleaned.

You can see that using Java 8, it was able to download all the dependencies successfully.

It's not ideal to have to use the command-line to get the dependencies downloaded, but once it's all cached locally, then you can switch back to STS to build and run grails-apps.

Sunday, November 25, 2018

Ignoring OSSEC rules

To ignore some errors in OSSEC we can configure our custom rules in /var/ossec/rules/local_rules.xml

In this case I'm going to ignore some Shibboleth errors I received in an email:

 OSSEC HIDS Notification.  
 2018 Nov 26 12:56:27  
 Received From: apn-lsrv01->/etc/httpd/logs/ssl_access_log  
 Rule: 31122 fired (level 5) -> "Web server 500 error code (Internal Error)."  
 Src IP: 150.203.1.1  
 Portion of the log(s):  
 150.203.25.3 - - [26/Nov/2018:12:56:25 +1100] "GET /Shibboleth.sso/NIM/Artifact HTTP/1.1" 500 937  
  --END OF NOTIFICATION  

I've highlighted the relevant parts we'll need in red font above.

Before we add new rules to ignore this error, we need to identify which group it belongs to.


 cd /var/ossec/rules  
 grep -lir 31122 .  
 ./web_rules.xml  

Here we can see that the rule 31122 exists in the file web_rules.xml. Therefore the group that the rule belongs to is 'web'

Now let's analyze how ossec will decode the log error using tool called ossec-logtest.
Start ossec-logtest, run the command: /var/ossec/bin/ossec-logtest
Then copy and paste the portion of the log you received in the email, and you should get a response similar to this:


 [root@apn-lsrv01 bin]# ./ossec-logtest  
 2018/11/26 13:08:06 ossec-testrule: INFO: Reading local decoder file.  
 2018/11/26 13:08:06 ossec-testrule: INFO: Started (pid: 8696).  
 ossec-testrule: Type one log per line.  
 150.203.25.3 - - [26/Nov/2018:12:56:25 +1100] "GET /Shibboleth.sso/NIM/Artifact HTTP/1.1" 500 937  
 **Phase 1: Completed pre-decoding.  
     full event: '150.203.25.3 - - [26/Nov/2018:12:56:25 +1100] "GET /Shibboleth.sso/NIM/Artifact HTTP/1.1" 500 937'  
     hostname: 'apn-lsrv01'  
     program_name: '(null)'  
     log: '150.203.25.3 - - [26/Nov/2018:12:56:25 +1100] "GET /Shibboleth.sso/NIM/Artifact HTTP/1.1" 500 937'  
 **Phase 2: Completed decoding.  
     decoder: 'web-accesslog'  
     srcip: '150.203.25.3'  
     srcuser: '-'  
     action: 'GET'  
     url: '/Shibboleth.sso/NIM/Artifact'  
     id: '500'  
 **Phase 3: Completed filtering (rules).  
     Rule id: '31122'  
     Level: '5'  
     Description: 'Web server 500 error code (Internal Error).'  
 **Alert to be generated.  

Here we can see that OSSEC decoded the log error with a url as '/Shibboleth.sso/NIM/Artifact'

This means when we write our rule to ignore this error, we need to specify the rule using a URL.

Now we can proceed to create our rule by editing the /var/ossec/rules/local_rules.xml by adding the following to the end of the file:


 <group name="web," >  
  <rule id="100032" level="0">  
   <if_sid>31122</if_sid>  
   <url>/Shibboleth.sso</url>  
   <description>Ignore Shibboleth</description>  
  </rule>  
 </group>  


  • In this rule we specified that the rule belongs to group called 'web'.
  • The rule ID to which we are processing has ID 31122.
  • And the URL should start with /Shibboleth.sso

We can rerun our ossec-logtest without having to restart OSSEC.
Now if we rerun ossec-logtest we should see the following:

 [root@apn-lsrv01 bin]# ./ossec-logtest  
 2018/11/26 13:11:17 ossec-testrule: INFO: Reading local decoder file.  
 2018/11/26 13:11:17 ossec-testrule: INFO: Started (pid: 9181).  
 ossec-testrule: Type one log per line.  
 150.203.25.3 - - [26/Nov/2018:12:56:25 +1100] "GET /Shibboleth.sso/NIM/Artifact HTTP/1.1" 500 937  
 **Phase 1: Completed pre-decoding.  
     full event: '150.203.25.3 - - [26/Nov/2018:12:56:25 +1100] "GET /Shibboleth.sso/NIM/Artifact HTTP/1.1" 500 937'  
     hostname: 'apn-lsrv01'  
     program_name: '(null)'  
     log: '150.203.25.3 - - [26/Nov/2018:12:56:25 +1100] "GET /Shibboleth.sso/NIM/Artifact HTTP/1.1" 500 937'  
 **Phase 2: Completed decoding.  
     decoder: 'web-accesslog'  
     srcip: '150.203.25.3'  
     srcuser: '-'  
     action: 'GET'  
     url: '/Shibboleth.sso/NIM/Artifact'  
     id: '500'  
 **Phase 3: Completed filtering (rules).  
     Rule id: '100032'  
     Level: '0'  
     Description: 'Ignore Shibboleth'  

After all that testing , we are now ready to release our changes by restarting OSSEC.

Wednesday, October 31, 2018

Exetel vs Myrepublic NBN speed test Canberra

Time 5:30pm

Exetel 

Download: 45.5 Mbps
Upload: 15 Mbps

MyRepublic

Download: 40 Mbps
Upload: 8 Mbps

Exetel is faster, cheaper and has better phone plans and provides static ip for free. Exetel wins hands down.