varnish compilation fails on or statement - varnish

I'm trying to allow logins on my site. So I setup the following in my VCL under varnish 4:
# Allow the beta site to login
if ( req.http.host ~ "^beta\.example\.com$" && req.url ~ "^?oa_social_login_source=custom$" ) {
return (pass);
}
But when I go to do a syntax check on the VCL I get the following error:
#varnishd -C -f default.vcl
Message from VCC-compiler:
Regexp compilation error:
nothing to repeat
('input' Line 111 Pos 62)
if ( req.http.host ~ "^beta\.example\.com$" && req.url ~ "^?oa_social_login_source=custom$" ) {
-------------------------------------------------------------##################################----
Running VCC-compiler failed, exited with 2
VCL compilation failed
Can anybody help me out with the syntax on what I'm trying to achieve?
Thanks,
Tim

You need to escape the question mark - as that is regexp quantifier sign.
req.url ~ "^\?oa_social_login_source=custom$"

Related

eslint enforce space after the single-line-if parentheses

I'm quite new to ESLint and I couldn't find a rule that does what I want. Consider the following code:
if(someCondition)i++;
I want to enforce a single space after the parentheses, so that we should have the following instead:
if(someCondition) i++;
However I simply couldn't find such a rule; it's not space-before-function-paren (obviously), keyword-spacing (which only affects the spacing after if) or space-before-blocks (since this is a single-line-if, there's no block). Please help. Thanks!
P.S. Same rule should apply to single-line-while as well.
https://github.com/eslint/eslint/discussions/15267#discussioncomment-1597748
I think we don't have that rule in the core.
keyword-spacing can disallow if (foo)return;, space-before-blocks can disallow if (foo){, but it seems that there is no rule that would disallow if (foo)bar; and enforce if (foo) bar;
Simple, but effective:
$ cat input
if (condition)i++;
if (condition)i--
while ( this ^ foo || bar )continue
for (true ||
true )z--
Naive solution, but probably ok.
$ cat input | busybox sed -e 's/)\([a-zA-Z_]\)/) \1/'
if (condition) i++;
if (condition) i--
while ( this ^ foo || bar ) continue
for (true ||
true ) z--
This will put a space between ) and the first letter of a variable name (a-z_).
Consider my answer here (and others') for tips on how to process all files that contain the undesired pattern:
https://unix.stackexchange.com/questions/675881/remove-trailing-spaces-from-text-files-only-when-necessary/676367#676367

Why do I get the error "Received usmStatsUnknownUserNames.0 Report-PDU with value 1" when I try to connect to my device using Net::SNMP?

I am trying to write a Perl script to do an SNMP get. It should work like the following command:
snmpget -v 3 -l authNoPriv -a MD5 -u V3User -A V3Password 10.0.1.203 sysUpTime.0
Returns:
SNMPv2-MIB::sysUpTime.0 = Timeticks: (492505406) 57 days, 0:04:14.06
But my Perl script returns the following:
ERROR: Received usmStatsUnknownUserNames.0 Report-PDU with value 1 during synchronization.
Last but not least, here is the Perl script:
use strict;
use warnings;
use Net::SNMP;
my $desc = 'sysUpTime.0';
my ($session, $error) = Net::SNMP->session(
-hostname => '10.0.1.202',
-version => 'snmpv3',
-username => 'V3User',
-authprotocol => 'md5',
-authpassword => 'V3Password'
);
if (!defined($session)) {
printf("ERROR: %s.\n", $error);
exit 1;
}
my $response = $session->get_request($desc);
my %pdesc = %{$response};
my $err = $session->error;
if ($err){
return 1;
}
print %pdesc;
exit 0;
I called the Perl script and snmpget on the same (Linux) machine. What could be causing this and how can I fix it?
As PrgmError points out, you're using a different IP address in your Perl script than in your snmpget command; I would double check that. The particular error you're getting indicates that your username is wrong; if the IP mismatch was simply a typo in your question, I would double check the username next.
A few other points about your Perl script:
Use die
You should use die instead of printf and exit since die will print the line number where it was invoked. This will make debugging your script much easier if there are multiple places it could fail:
die "Error: $error" if not defined $session;
will print something like
Error: foo bar at foo.pl line 17.
Also, using return inside an if statement doesn't make any sense; I think you meant to use
if ($err) {
exit 1;
}
but you should die with the specific error message you get instead of silently failing:
die $err if $err;
Fix arguments to get_request
Your invocation of the get_request method looks wrong. According to the docs, you should be calling it like this:
my $response = $session->get_request(-varbindlist => [ $oid ]);
Note that Net::SNMP only works with numeric OIDs, so you'll have to change sysUpTime.0 to 1.3.6.1.2.1.1.3.0.
Looking at your script I noticed that hostname value has 10.0.1.202
but the snmpget command you're using has 10.0.1.203
wrong IP by any chance?

While loop in makefile

I've got following make file:
n ?= 10
all:
while [[ $${n} -gt 0 ]] ; do \
echo $$n ; \
((n = n - 1)) ; \
done
And when I'm trying to run it (make), run fails with error:
make: *** [all] Error 1
I can't understand the reason of this fail.
Any help appreciated.
Just to note: you are causing your makefile to be extremely non-portable. Make always invokes recipes using /bin/sh. The recipe you've written is actually a bash script and won't work with a POSIX /bin/sh; it will only work on systems which use /bin/bash as /bin/sh. Many (most, depending on how you count them) do not.
You can rewrite:
n ?= 10
all:
n=$(n); \
while [ $${n} -gt 0 ] ; do \
echo $$n ; \
n=`expr $$n - 1`; \
done; \
true
A rule examines the last return code. If it is nonzero, make raises an error.
In your case, the last retrun code is the result of (( n = n - 1)) for n=2, i.e. 1.
To avoid the error, simply modify the line 5 to:
((n = n - 1)) || true; \

Entity Framework5 Code-First when change a table manual and broke the migration

I think I completely broke my migration I delete my migration folder and delete my table migration that generated in the database. why? for I read something that i have to delete those so I dit
and now cant make it work
I tried to use in my app_star and in a constructor in EfDbContext
Database.SetInitializer(new DropCreateDatabaseIfModelChanges());
this in my method OnModelCreating
modelBuilder.Conventions.Remove();
i get this error using PM> Enable-Migrations-ProjectName EnableAutomaticMigrations Rhld-Force-Verbose
Enable-Migrations: There is no positional parameter that accepts the argument 'EnableAutomaticMigrations'.
At line: 1 Char: 1
+ Enable-Migrations-ProjectName EnableAutomaticMigrations Rhld-Force-Verbose
+ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
     + CategoryInfo: InvalidArgument: (:) [Enable-Migrations], ParameterBindingException
     + FullyQualifiedErrorId: PositionalParameterNotFound, Enable-Migrations
and using PM> Update-Database -ProjectName rhld -Verbose -Force
Using StartUp project 'Rhld'.
Specify the indicator '-Verbose' to see the SQL statements that are being applied to the target database.
Not found any migration configuration in assembly 'Rhld'. (In Visual Studio, you can use the command Enable-Migrations of the Package Manager Console to add a migration configuration).
so my question is what can I do now?, i will like to still using my database
i tried to create the tables in another database and can't do it get the same error
Edit
my problem was that is was working fine at the begining then try to change a foreing key both the name and the table, and i can't so I begin to read and delete thing :S
well I end delete de database and
public EfDbContext()
{
Database.SetInitializer<EfDbContext>(new DropCreateDatabaseIfModelChanges<EfDbContext>());
}
in Application_Start
Database.SetInitializer(new DropCreateDatabaseIfModelChanges<EfDbContext>());
don't know what did the trick
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
}
and use this and it work
Enable-Migrations -EnableAutomaticMigrations -ProjectName rhld -Force
Update-Database -ProjectName rhld -Verbose -Force

How can I find out the meaning of an error code when unzipping a file using Perl?

I'm trying to unzip a file using perl on linux. The file is password protected, and am looping through possible password in a brute force attack (yes this is a homework assignment)
I have isolated and removed ther error code 20992 (bad password), but am still getting another error code which is not listed anywhere in the docs, and couldn't find anything relevant using The Googles either.
The error is:
512 error: invalid compressed data to inflate secret_brute.txt
Has anyone seen this error message? If so, what mean?
#!/usr/bin/perl
#aaaa_zzzz = ("aaaa" .. "zzzz");
foreach(#aaaa_zzzz){
$output = system("unzip -P $_ -q -o secret_brute.zip");
if($output !~ m/20992/){ # <-- filtering out other error message
chomp($output);
print "$_ : $output\n";
}
}
Edit
Per request: Secret_brute.zip
Here is a list of exit codes from unzip.
As mentioned, perldoc -f system explains how to get the exit value of unzip:
If you'd like to manually inspect system's failure, you can
check all possible failure modes by inspecting $? like this:
if ($? == -1) {
print "failed to execute: $!\n";
}
elsif ($? & 127) {
printf "child died with signal %d, %s coredump\n",
($? & 127), ($? & 128) ? 'with' : 'without';
}
else {
printf "child exited with value %d\n", $? >> 8;
}
In this case, a value of 512 would map to:
2: A generic error in the zipfile format was detected. Processing may have completed successfully anyway; some broken zipfiles created by other archivers have simple work-arounds.
On the other hand, 20992 would map to:
82: No files were found due to bad decryption password(s). (If even one file is successfully processed, however, the exit status is 1.)

Resources